0

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;
};
3
  • 2
    I'm stuck too. What is your question, or what do you need help with? Commented Aug 4, 2016 at 20:57
  • I'd suggest not to hardcode one of the operand. You may want to try the more generic var multiply = function(a, b) { return a * b; }. Usage : var c = multiply(3625, 9824); Commented Aug 4, 2016 at 21:05
  • You could start off with this tutorial. Take a look at the example for square. After you get done with this one, it would probably be helpful to go through the other tutorials in this guide. Commented Aug 5, 2016 at 5:12

5 Answers 5

1

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^
};
Sign up to request clarification or add additional context in comments.

1 Comment

Just like in math: f(x) = x * 9824 becomes function f(x) {return x*9824}
0

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!

Comments

0

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

Comments

0
function add(a,b)
{
   return (parseInt(a)+parseInt(b));
}

function multiply(a,b)
{
   return (parseInt(a)*parseInt(b));
}

var result = add(mutiply(3625,9824),777);

Comments

0

Try this:

function add(a, b) {
   return a + b;
};
var resultAdd = add(9824, 777);

function multiply(a, b) {
   return a * b;
};
var result = multiply(resultAdd, 36325);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.