Help: Functions with two parameters


Write a function called perimeterBox that returns the perimeter of a rectangle.
It should have two parameters.
One formula for perimeter is length + length + width + width;
Call the function and pass in any value for length and width you like.
After i run my code.I am getting the error message: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.

Here is my code:
var perimeterBox = function(length, width) {
return length * width;
var newNumber = perimeterBox(5,4);



HI this line

return length * width;

change it to

return  2 * (length + width);


@wizmarco,thanks so much:grin:


return length + length + width + width;

and to call the function:
perimeterBox(4, 6);

where 4 and 6 are the numbers you input


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