Trying to understand this scope exercise that I came across this site's exercise. How exactly is function doMultiplication
being called within function writeIt
? Every time I try to figure out this seemingly simple exercise, I get cross-eyed. Can you break it down to explain how this one works, please? Thanks in advance.
function writeIt(numTimes, multiple) {
function doMultiplication(val, multiple) {
i = val * multiple;
return i;
}
for (let i = 0; i < numTimes; i++) {
document.write(doMultiplication(i, multiple) + ' ');
}
}
writeIt(5, 2);
EDIT - here's my understanding of what's going on so it can be clarified what I'm not understanding here ...
So, with the writeIt(5, 2) function, it means that 2 is being multiplied to val? But what is val here?
I get the for equation, and how numTimes is 5 ... I think I'm being thrown off by the val part?