What makes a higher-order function?

Higher-Order Functions and iterators Quiz

In this lesson quiz, they ask what represents a higher-order function. I was stuck between:

let multiplyTwoValues = (val1, val2) => {
    return val1 * val2;
}

and

let getFunctionString = (func) => {
    return func.toString();
}

Why is multiplyTwoValues wrong? Aren’t val1 and val2 considered parameters? Does return val1 * val2 not count as a function getting returned?

1 Like

Hi there,

So, return val1 * val2; is not a function–hence the wrong answer. Simply remember that higher-order functions are those that take a function as an argument or return the function as output.

1 Like

This is an expression. It will be evaluated, and the result will be returned.

This function takes a function as an argument. The parameter func is assigned to that argument.

2 Likes

thank you for your guidance!

1 Like