Fernando_Diniz 0 Posted May 21 Report Share Posted May 21 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 post Share on other sites

Zex 11 Posted May 21 Report Share Posted May 21 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 post Share on other sites

## 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 account## Sign in

Already have an account? Sign in here.

Sign In Now