Fernando_Diniz Posted May 21, 2021 at 09:22 PM Report Share #622385 Posted May 21, 2021 at 09:22 PM Start by repeating the code you wrote for the last section (the calculate and add functions). Declare a variable multiply and assign to it a function declaration taking two arguments, operand1 and operand2, and which returns the result of the multiplication of the arguments. Invoke calculate twice, passing it as a third argument the add and multiply functions respectively. Alguém para ajudar ?? var add = function (operand1, operand2){ return operand1 + operand2; }; var calculate = function (operand1, operand2, operation) { var result = operation(operand1, operand2); console.log(result); }; var multiply = function (operand1, operand2) { return operand1*operand2; }; calculate=(4,4,add); calculate=(4,4,multiply); Link to comment Share on other sites More sharing options...
Zex Posted May 21, 2021 at 11:55 PM Report Share #622386 Posted May 21, 2021 at 11:55 PM var add = function (operand1, operand2){ return operand1 + operand2; }; var multiply = function (operand1, operand2) { return operand1*operand2; }; var calculate = function (operand1, operand2, operation ) { var result = operation(operand1, operand2); return( result ); }; console.log( calculate(4,4,add) ); console.log( calculate(4,4,multiply) ); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now