Without changing this function:
function operate(operator, operand1, operand2) {
return operator(operand1, operand2);
}
I want to write out:
var x = operator(add, operate(add, 2, 3), operate(multiply, 4, 5));
And get 25 as a value of x. How can I do this?
The reason being that
operatoris expected to be a function, but execution requiresaddandmultiplyto be defined as:Also, I think there’s a typo:
I would have:
This gives
x = 25.