Create a function sumOrProduct
that accepts the following four arguments.
- A number.
- Another number.
- A string, the value of which will either be "sum" or "product".
- A callback function
printResult
.
Based on the string value, the sumOrProduct
function will either add the numbers received as arguments or multiply them and store their result. If the string is neither "sum" nor "product", the function should log to the console "Invalid parameter".
Also, we need to create a second function printResult
that accepts 2 arguments,
- A string, which will be the same string passed to
sumOrProduct
.
- The result.