Need help


Functions with two parameters

So far we've only looked at functions with one parameter. But often it is useful to write functions with more than one parameter. For example, we can have the following function:
var areaBox = function(length, width) {
return length * width;

With more than one parameter, we can create more useful functions

To call a function with more than one parameter, just enter a value for each parameter in the parentheses. For example, areaBox(3,9); would return the area of a box with a length of 3 and a width of 9.


  1. Write a function called perimeterBox that returns the perimeter of a rectangle.
  2. It should have two parameters.
  3. One formula for perimeter is length + length + width + width;
  4. Call the function and pass in any value for length and width you like.

this is what I did!!!!

var perimeterBox=function (10)(10)(5)(5)
return length+length+width+width


SyntaxError: Expected identifier


look at the example:

var areaBox = function(length, width) {
    return length * width;

you have function() between the ( and ) you can add multiply parameters and separate the parameters with a ,, no need to add so many parentheses:

var perimeterBox=function (length, width)

and your {} are missing.


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