troubleshooting Question

callback function

Avatar of Temir Aliev
Temir AlievFlag for United States of America asked on
JavaScript
7 Comments1 Solution144 ViewsLast Modified:
/*
Instructions

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.
This function should return a callback invoked with the appropriate arguments.

*/

function add(num1, num2){
  return num1 + num2;
}

function multiply(num1, num2){
  return num1 * num2;
}

function math(num1, num2, callback){
  if(callback == "add"){
     add();
  } else if( callback == "multiply"){
     multiply();
  }
}

console.log(math(2, 5, 'add'))



//WHY IS MY CALLBACK NOT WORKING?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros