HIGHER-ORDER FUNCTIONS - Functions as Parameters,

Hi there,
Maybe this paragraph is no well written, because I had a hard time trying to understand it.

2.
Write a higher-order function, checkConsistentOutput() . This function should have two parameters: a function and a value. It should call the argument function with the value two times. If the callback function produces the same result twice, it should return the result of the function call, otherwise, it should return the string 'This function returned inconsistent results'

so here we go:

1.- Write a higher funtion called: checkConsistentOutput()
2.- add two parameters, (first is a function, second is a value)
3.- It should call the argument function with the value two times ( here, very confusing. I saw the answer but still can’t understand this direction. :frowning: )

4.- If the callback function produces the same result twice, it should return the result of the function call… (where is the callback function, whats the name?

very confusing…

const addTwo = num => num + 2;

Now, in the call expression we see this function reference passed as an argument…

console.log(checkConsistentOutput(addTwo, 5));
                                    ^
                                 callback
4 Likes