13 function review ,where is wrong?


#1

// Accepts a number x as input and returns its square
var square = function (multiply) {
return 2 * 3;
};
square(multiply)
// Write the function multiply below
// It should take two parameters and return the product


#2
var square = function (x, y) {
return x*y;
};
square(2, 3);

In the parameters you put the "names" of the parameters which will be used inside the function. The value of them are defined when you call the function, inside the parenthesis. In this case, you set 2 parameters, x and y, separated by a comma. Inside the function, you multiply them and return the product. When you call the function, you define the parameters as 2 and 3. Therefore, x and y, now have the values 2 and 3.


#3

not working ,Oops, try again.
Make sure you defined a function called multiply


#4

// Accepts a number x as input and returns its square
var square = function (x) {
return x * x;
};

// Write the function multiply below
// It should take two parameters and return the product
var square = function (x , y) {
return x * y;
};

square(2,8);

Oops, try again. Make sure you defined a function called multiply


#5

@santiczop
Your code is only partially correct.

@textwhiz86979

// Accepts a number x as input and returns its square
var square = function(x) {
return x*x;
};

And now the function multiply

// Write the function multiply below
// It should take two parameters and return the product
var multiply = function(x,y){
  return x*y;  
};
multiply(2,3);

#6

thanks a lot,It is so simple.I tried to figure it out long time, didn't know why.lol...


#7

My code was perfectly correct... It did work and I was correcting everything he did. I started from his code. Not my problem if he didn't even knew how to define a function's name


#8

Did you read the Comments?

// Accepts a number x as input and returns its square

and your Code dont do that

var square = function (x, y) {
return x*y;
};
square(2, 3);

With that we get an rectangle and not square

It is only right for the second task.
And there you didnt designate the function correct.

// Write the function multiply below
// It should take two parameters and return the product