Explain this problem

Hello everyone, explain this program :confused:

function multiplier(factor) {
  return number => number * factor;

let twice = multiplier(9);
// → 90
1 Like

Your multiplier function returns a function with one parameter number (it’s your arrow function : the F function below).

So multiplier(9) returns a function F where factor is 9 then when you call twice(10) you just call this returned function F with number set to 10. This function F returns a number = number * factor = 10 * 9 = 90.

1 Like

thank you so much :smiley:

You’re welcome :wink:

This is an example of currying. See https://hackernoon.com/currying-in-js-d9ddc64f162e for a more general discussion on this topic

thanks… :+1:t2: