Exercise One: In this exercise you will be creating two functions.
// Function One: Will be called 'multiply'. // This function will take two parameters, both numbers // This function will return the two numbers multiplied together.
// Function Two: Will be called 'calculator'. // This function will take three parameters, // First will be a callback function, // Second and Third will be numbers. // This function will return the two numbers passed into the callback function.
// NOTE: You can use the multiply function to test the calculator function, but understand that // other callback functions will be passed into it as a test.
When we create the function, we use variables for parameters. For this case, p1 and p2 must be treated like numbers otherwise program may throw errors.
function calculate(callback, p1, p2)
{
...
}
calculate(multiply, 1, 6);
// callback will get multiply
// p1 will get 1
// p2 will get 6
Exercise One: In this exercise you will be creating two functions.
// Function One: Will be called 'multiply'.
// This function will take two parameters, both numbers
// This function will return the two numbers multiplied together.
// Function Two: Will be called 'calculator'.
// This function will take three parameters,
// First will be a callback function,
// Second and Third will be numbers.
// This function will return the two numbers passed into the callback function.
// NOTE: You can use the multiply function to test the calculator function, but understand that
// other callback functions will be passed into it as a test.
@faziz6006
Somewhere in the program someone will call
calculate(...)
They are responsible for putting numbers in the parameters:
When we create the function, we use variables for parameters.
For this case, p1 and p2 must be treated like numbers otherwise program may throw errors.