9. Functions with two parameters help


#1


It says: 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.


// Write your function starting on line 3

var perimeterBox = function(length,width) {
return 9 * 4;
};
perimeterBox(1,1);

How to fix this?


#2

I think you should write like this :

return length*width ;


#3

your function should return the width + width + length + length.

Use the function parameters for this. You do understand how parameters work right? They are placeholders, and then when you call the function:

perimeterBox(1,1);

height and width get assigned the value of the arguments you pass into the function when calling the function, this way your function can caculate the perimeter for different values:

perimeterBox(1,1);
perimeterBox(4,5);
perimeterBox(3,2);

#6

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