I’m on the 3rd of 4 lessons in this higher order functions section.
I’m kind of getting the grasp of this, I think.
If i have a function, i can pass another function as an argument.
Here’s a very simple, very convoluted example I’ve made up to try to explain my understanding of this, and hopefully my confusion.
const funcOne = (func) => return funcOne + 20; const funcTwo = (num) => num + 10 ; funcOne(funcTwo);
I got a little confused at the end there lol. Essentially, funcTwo should take a number, add 10, pass it to funcOne, funcOne should add 20.
I’ll be sleeping soon, but i’ll check this in the morning. Please help me figure this out, i feel like i’ve hit a stumbling block ! Thanks
Edit begins here:
I did a little fiddling with it in the codecademy console. This works, but i’ve invoked the second function as an argument of the first function (and fixed things so they work as intended.)
However, I’m still not getting my original issue: Why does the exercise say not to invoke the function when it’s called as an argument. Infact, scrap that. Can anyone please just explain this to me like i’m stupid (don’t worry, i probably am xD).
Here’s the refactored code:
const funcOne = (func) => func + 20; const funcTwo = (num) => num + 10 ; console.log(funcOne(funcTwo(10))); // The (10) at the end is invoking funTwo, then passing it to funcOne?