First of all, I am sorry for not understanding by reading it and I am a beginner in javascript. I am learning better with examples which I am familiar with.
function multiplier(factor) {
return number => number * factor;
}
let twice = multiplier(2);
console.log(twice(5));
// → 10
I was reading Eloquent_Javascript book and I encountered with this code. I basically understand the intention of the code and the result. I don't understand why does this give this result. Shouldn't be twice equal to 4 since multiplier should multiply 2 at first place then the result 20? For a split second, I kind of understand but still confused.