Lesson 9 ? function to parameters?


// Write your function starting on line 3

var perimeterbox = function(length,length,width,width)
    return length + length + width + width ;
perimeterbox (4,4,4,4);

This is correct I think but has a "Oops, try again. It looks like your perimeterBox function doesn't return the correct perimeter (4) for a width of 1 and a length of 1." error


I'm pretty sure it's because you have perimeterbox (4,4,4,4) when it should be (1,1,1,1)

or more efficiently

var perimeterbox = function(length, width) // you only need to have one of each. If this were a different shape you'd have to label it instead with (length1, length 2, length 3, width1, width2, width3) or whatever is best. But since it's a rectangle, both length's are equal and both widths are equal. Only need one length and one width. T

premiterbox(1,1); //bam!


That doesnt work. The lesson ask us to use

return length + length +height + height;


var perimeterbox = function(length,lenght,width,width)

will have to work..I dont know whats wrong...


// Write your function starting on line 3

var perimeterbox = function(length,width)
return length + width ;

I also tried this one...


Oh I see. Then it's probably just the lesson being annoying and too strict. ... as usual lol

So then use your original code but instead


if that doesn't work please link the lesson so i can see exactly what has it's panties in a bunch.


Please I need help, is it the browser or something else because I think the code is good..Thanks


As I said, put the direct link to your lesson in a post.


O.K. what do you mean by link? the link to my account ?

Here is the code Im using now.

var perimeterbox = function(length,length,width,width)
return length + length + width + width

perimeterbox (1,1,1,1);


I tried the code online and it works fine...


Hello @kachidousa

The instructions from that link specifically ask for you to create a function called perimeterBox that has only 2 parameters. They even give you an example of a return statement to use. I'm not sure why you have 4 parameters in your function. If you make slight alterations to the function name and the return statement in the code below, you will pass the exercise.


I tried that earlier and it does not work. I tried copying your code and it does not work...
Im getting

Oops, try again. Did you define a perimeterBox function?


I didn't give you code to copy. I selected the code you wrote that was the closest to a solution. Use the instructions.

They want a function called perimeterBox, not perimeterbox. They want the function to take two parameters, not four parameters. They give you a return statement of length + length + width + width.

That should be what you write as code.


I have corrected the perimeterBox , I found that error but I tried all the other ways and nothing...


Post your code anytime you make corrections so we can have a look :slight_smile:


/// Write your function starting on line 3

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

I got it to work , Thanks


Glad you worked it out :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.