I just started learning js from EloquentJavascript I need 2 answers to help me pass this example:
function makeAddFunction(amount) {
function add(number) {
return number + amount;
}
return add;
}
var addTwo = makeAddFunction(2);
var addFive = makeAddFunction(5);
show(addTwo(1) + addFive(1));
Question 1:
Can we just add () after variable meaning to add argument to the function that the variable represent? like addTwo(1) means makeAddFunction(1)?
Question 2:
makeAddFunction(2) means amount = 2, then what's the value for number? If I pick a section of the above example, what will return in the following section?
function makeAddFunction(2) {
function add(number) {
return number + 2;
}
return add;
}