Can you make a function a parameter of another function?

It’s my understanding that you can use a function as an argument when invoking a function. I’m clearly doing it wrong. Can someone help me to understand what I’m doing wrong here? I thought if I invoked functionTwo with functionOne as an argument, then it would log “hi” to the console?

let functionOne = (a) => {
console.log('hi');
};
let functionTwo = (b) => {};
functionTwo(functionOne);

try adding b() inside the body of functionTwo, so that there is the function call in the body

you still need to call the parameter, it is what you are missing here, you are calling one function but not the other, if you don’t call a function, nothing happens

1 Like

Look up ‘callbacks’, that should help.

1 Like