Codecademy Forums

Functions as parameters: Understanding multiple function evaluation

hey, I wrote for number 2:

const checkConsistentOutput = (funk, val) => {
if (funk(val) === funk(val)) {
return funk(val);
} else if (funk(val) != funk(val)){
return “This function returned inconsistent results.”
}
};

would the function “funk” evaluate twice in this context?

It would, since it is called twice in the first condition. That would result in it being called a third time.

If the first condition fails, it would be called a third and fourth time in second conditional.

The logic is a little in doubt, though. We would not need the second condition (else if) since it is only the opposite of the first. In this case else is all we would need.

Aside

func is short for function. What is funk short for? It’s a good idea to use variable names that have meaning relating to the program and the purpose they serve.