9
JS Assignment 4: Control Flow Continued
BrianTran2 (9)

Is anyone doing LambdaSchool JavaScript pretest because I have worked for 40 minutes and I can get question 3 from assignment 4 correct.

You are viewing a single comment. View All
1
Cwill14 (10)

@faziz6006

function multiply(num1, num2) {
   return num1 * num2;
}
function calculator(cb, n1, n2) {
   return cb(n1, n2);
}
calculator(multiply, 2, 4); // this should return 8

a callback function is a function being passed as a parameter to another function. this helps keep the code DRY (don't repeat yourself), because we can pass the calculator function all types of math operations by putting, for example, multiply and the two parameters that will go into multiply. Hope this helps!