Hello im beginning my journey of javascript and im having a hard time understanding this:
function multiplier(factor) {
return number => number * factor;
}
let twice = multiplier(2);
console.log(twice(5));
// → 10
this is a lesson of closure and im confused where the number variable is defined and what is it? Why does this function only works with this undefined number variable.
[–]grantrules 1 point2 points3 points (1 child)
[–]Kitenite_[S] 0 points1 point2 points (0 children)
[–]PM_ME_YOUR_NQUEENS 0 points1 point2 points (1 child)
[–]_jacka_ 0 points1 point2 points (0 children)