How common is question related to currying for junior web role?

It looks like your second solution is wrong, at least according to the requirements.

const functionCurrying = function(...fns) {
  return (param) => {
   return fns.reduceRight( (partial, currentFn) => { 
     return currentFn(partial);
   }, param);
  };
}

I've changed some names, sorry. I tried to keep that to a minimum. The problems are:

  • When you collect fns (args in your version) with ... that already gives you an Array. You don't need Array.from.
  • reduceRight instead of reverse + reduce. Not really an error but preferable.
  • You completely changed the way it worked from the first version to the second. In the second one, instead of passing the result to the next function, you're calling each function with the original parameter and simply getting the sum of all the results.
  • Not only that, but you have a bug, where instead of calling current (currentFn in my version) -the function of the current iteration-, you're trying to call args -the whole array of functions- as a function.

In an unrelated note, the question doesn't really seem to be about currying. I didn't change the name of your function to avoid adding more noise, but I would suggest calling it compose.

Finally, no, I wouldn't consider this an appropriate question for a junior position, unless there were special circumstances.

/r/javascript Thread