Help: Functions with two parameters


#1



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


nstructions
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.

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

`


#2

HI this line

return length * width;

change it to

return  2 * (length + width);

#3

@wizmarco,thanks so much:grin:


#5

alternatively:
return length + length + width + width;

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

where 4 and 6 are the numbers you input


#6

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