9 help


what do I do for 9?

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


Have you tried typing "function"? :slightly_smiling:


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?


The problem was you should only have TWO parameters.

var perimeterBox = fuction(length, width)


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);


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!


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?


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);


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


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);


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:


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.


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