1

In the below function assigning the multiplier function on twice variable so the factor parameter 2 should be replaced by 5 & how the number getting defined? The value of number is 5 and factor is 2 but how? Please explain.

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

let twice = multiplier(2);
console.log(twice(5));
  • 1
    no, `number` argument is 5, `factor` is 2 - `twice` is a function that returns `2` times the argument supplied to it ... – Jaromanda X Apr 17 '19 at 06:43
  • Thank You @JaromandaX but how the code determine that the argument is 5 as there is only one place for parameter. In addition, can you please explain what's the **arrow** (`=>`) is doing here. If the **arrow** (`=>`) is removed from return statement the number becomes undefined. **ReferenceError: number is not defined (line 3 in function multiplier)** – MAHFUZ AFTAB Apr 18 '19 at 11:09
  • Got the answer [link](https://stackoverflow.com/questions/38739810/can-someone-explain-me-the-flow-of-this-javascript-function-closure-concept) – MAHFUZ AFTAB Apr 21 '19 at 06:53

0 Answers0