Lesson 9, functions with two parameters


#1

They say you must return with a perimeter value of 4(eg. perimeter(4)).

This is my code:

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

what's wrong with it?


#2

why 4 parameters? you can easily use a parameter multiply times:

var example = function(x){
   return x + x + x
}

no need for 4 parameters/arguments, two is enough.


#3

Thanks.

But for future purposes, Does this really matter?


#4

yes, since variable can be overwritten, so can function parameters, so using the same parameter name is wrong


#5

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