perimeterBox function


I am trying to write and execute a perimeterBox function for javascript Functions with 2 parameters lesson. I get an error msg telling me that my perimeterBox function doesnt return the correct perimeter.
Can someone help me out with this?

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



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


You have 4 parameters where 2 of them have the same name. So if you'd assign not 1,1,1,1 where they are all equal but 1,2,3,4 what would length + length + width + width be? 1+2+3+4, 1+1+3+4, 2+1+3+4 ... you see the point? It is ambiguous so giving an error is actually a valuable service from the language as you now no that there is something problematic instead of giving you unintuitive or even changing results whenever you run it.

So to fix this think about if you really need 4 variables instead of just 2, they're not 1 time-use only so...


thanks - will give this a try.


To simplify the code even more for this instance:

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


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

This is the right code for it!