I am trying to write a function that solves the following math problem: 3625 * 9824 + 777, using only two functions: "add" and "multiply". I am stuck here:
var multiply = function (number) {
return * 9824;
};
You need to refer to the function's argument (number) to "tell" javascript what you're multiplying:
var multiply = function (number) {
return number * 9824;
// Here^
};
f(x) = x * 9824 becomes function f(x) {return x*9824}Good start.
Remember that the function parameter (in this case, number) can be used as a variable inside the function itself. In your case, you want to multiply whatever number is passed in and return the result. So what you'd be looking for here is:
var multiply = function(num) {
return num * 9842;
}
:) Good luck!
first create your functions:
function add(a, b){
return a+b;
}
function multiply(a,b){
return a*b;
}
then you can call them...
let ans = 0;
ans = multiply(3625, 9824);
ans = sum(ans, 777);
console.log("3625 * 9824 + 777 = ",ans);
Keep going :) and this apply to all functional languages :D
var multiply = function(a, b) { return a * b; }. Usage :var c = multiply(3625, 9824);square. After you get done with this one, it would probably be helpful to go through the other tutorials in this guide.