Lesson 9, functions with two parameters


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;

what's wrong with it?


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.



But for future purposes, Does this really matter?


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


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