Functions with two parameters


#1

// Write your function starting on line 3

var perimeterBox = function(3, 9) {
return 3 + 3 + 9 + 9;
}

What am I doing wrong?


#2

First of all read the instructions

  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.

Than look at your code

// Write your function starting on line 3

var perimeterBox = function(1, 1) {
 return 3 * 5;
}

Where is the Formular for a Perimeter?
Where do you call your function?
Why do you try to give paramter with name "1" and "1" better would be lenght and width

And please dont edit your code after asking


#3

I did as you said, but an error


#4

var add = function(a, b) {
 return a + b;
}

add(1,2);

Return is 3

This should help you to think about your code.
I could give you the right Syntax but than you didnt learn anything.


#5

Here is my code, and it is correct:

// Write your function starting on line 3

var perimeterBox = function(a, b) {
return a + a + b + b;
}
perimeterBox(2, 3);

Thank you!
I thought I needed a number or string


#6

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