13. 13 Function review


#1



Jeez, I am stuck at 13. I am not the best at parameters.


My error message is: SyntaxError: missing ) after formal parameters
my code is below

// 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 multiply = function (y, square(2)){
    return square * y;
};


#2

Remove the (2) in the function multiply and then call the function at the end of the code.

Hope that helps.


#3

Now I get this
SyntaxError: missing before statement
I have removed the (2) on the square and put the (2) at the end like this

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

#4

When I ran your first code I got: SyntaxError: Unexpected token (

I removed the (2) completely an then I added multiply(); at the bottom.

var multiply = function (y, square){
return square * y;
};
multiply();

That worked for me.


#5

It worked, but I doesn't feel right, it says just NULL, but it worked, so, THAT'S GOOD! Thanks!


#6

Yes it didn't feel right to me either, but hey if it works then it works. :smile:


#7

I'm new at JavaScript but I don't think you are suposed to insert the square function in the multiply function at all.

Just:

var multiply = function(x, y) {
return x * y;
};
multiply(2,5);


#8

simplest is to do

var multiply = function(x, y) {
return x * y;
};
multiply();

but it's never wrong to put more stuff


#9

I have the same, didn't add the last line, it said got to call multiply at least once,
(thanks btw) I don't think its meant to be that complicated.