This is confusing - 9. Functions with two parameters


#1



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


It's not that I get an error but the return is not correct still I get the 'Way to go!' How can this be? Shouldn't the result be something like 14'ish?:slight_smile:


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

perimeterBox(2,2,5,5);


#2

no,
actually when you called perimeterBox(2,2,5,5)
first two value goes to first two parameter
that is 2 goes to length and 2 goes to width
because you have only two parameter length and width
so your result is 2+2+2+2=8

dont need 5 and 5 as you have only two parameter
if you want to add next two value then need two parameter too

@turistik


#3

Thank you rcodeman, really helpful :smiley:


#4

but I have given four values for two parameters...isn't that contradicts your statement


#5

but last two value is not working here
length + length + width + width
2+2+3+3

@turistik


#6


We have to use only two parameter not four :slight_smile:


#7

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

this is my code :wink: