9 help


#1

what do I do for 9?

> var perimeterBox = fuction(length, legth, width, width) 
> { 
>     return length + length + width+ width;
> };

#3

Have you tried typing "function"? :slightly_smiling:


#4

I'm having the same problem -- but I checked for typos.

var perimeterBox = function(length, length, width, width) {
return length + length + width + width;
};

perimeterBox (1, 1, 1, 1);

It said that my function perimeterBox doesn't return the correct perimeter (4) -- but it does. What am I doing wrong?


#5

The problem was you should only have TWO parameters.

var perimeterBox = fuction(length, width)

NOT

var perimeterBox = fuction(length, length, width, width)

If you are still confused, here's the full code

var perimeterBox = function(length, width){
    return length + length + width + width;
};

var newPerimeter = perimeterBox(1,1);
console.log(newPerimeter);

#6

Thanks for the help! That solved it for me!

When my conceptual model or logic doesn't match how I think the language should work I always get stuck... It's happened a few times during these JS exercises!


#7

In this case the problem with your logic would be that it is ambiguous what you mean e.g. what if you call your function with perimeter(1,2,3,4). Does using length in the function uses the first parameter with a value of 1 or the second of a value of 2?


#8

the problem calls for TWO parameters, length and width so length has one static value as well as width

anyways here's my code and i continue to get a "parentheses" error

var perimeterBox(length, width) {
return length + length + width + width;
};

var newPerimeter = perimeterBox(1,1);
console.log(newPerimeter);


#9

here you miss a = and a function keyword between perimeterBox and the parameters.


#10

I had some trouble with this and finally got it right, but I'm not sure why exactly. Anyways, I thought I'd include it as it's a bit different from what gracie017 posted. I didn't need to rename the variable or use the console.log.

Here's the right (accepted) code:

var perimeterBox = function(length, width)
{return 2*length + 2*width};

perimeterBox(1, 1);


#11

2*length = 2length is the same as length + length = 2length

Use any of the two formula, then your program will give you the same output :slightly_smiling:


#12

mathematically right but afaik js will reject this because it things that a variable starts with a number when it is not allowed to do so.


#13

Yep, im just illustrating to boardcoder48497 that 2*length and length + length has the same result. Different formula but the same result.