perimeterBox function seems not to validate


#1


https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/2/1?curriculum_id=506324b3a7dffd00020bf661#


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.


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

perimeterBox(4,4,3,3);


#2

Why do you have two of the same parameters?
Won't it be better if it's just length and width instead of length, length, width, width in function(length, length, width, width)?


#3

I was trying to make it work for a polygon of various side lengths.

var perimeterBox = function(length1, length2, width1, width2) {
    return length1 + length2 + width1 + width2;
};

perimeterBox(4,4,3,3);

This is how is should have been, but I realise why it was not working.

The task asked to use only 2 parameters.

I didn't read the task properly. My bad.

Thanks anyway for responding fat cat.


#4

If it's a polygon with varying sides, then it would be fine. But I think Codecademy wants a rectangular box and not a trapezoid, rhombus, etc. (they should be more specific on that tbh).

Haha, no problem! have fun coding :slight_smile:


#5

I always have fun :smile: :smile: :smile:


#6

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