I was given a prompt to complete and this is what is says
Write two functions, one called add and one called multiply, that each takes in two numbers and returns the appropriate new value.
Write a function called math that takes in two numbers, and a function 'operator' as parameters.
I have almost completed the problem and am stuck as to what to do to finish, any help would be appreciated. This is what I have.
function add(num1, num2){
return num1 + num2;
}
function multiply(num1, num2){
return num1 * num2;
}
function math(num1, num2, func){
return func();
}
math(1,2,add);
the log is only returning nan and i am not sure why it is not a number, I am also not sure if the code is written how they want with callbacks?
You should change math function to use num1 and num2 when you call func
function math(num1, num2, func){
return func(num1, num2);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With