9. Functions with two parameters


#1

I get an answer in the screen but below my code I get an error message stating "It looks like your perimeterBox doesn't return the correct perimeter(4) for a width of 1 and a length of 1". The instructions state you can use what ever parameters you want, so I'm not sure why it's asking for a length and width of "1" in the error message.

var perimeterBox = function(length, width) {
      return(length * length * width * width);
};
perimeterBox(4,6)

#2

Well remember perimeter is length PLUS length PLUS wideth PLUS wideth :smiley: times is area


#3

do you know how to find the perimeter of an object? It's the outside lengths added together. :))


#4

It's even given in the Hint.

For anybody who likes Maths,

length + length + width + width

but length + length is equal to 2 * length; and, width + width is equal to 2 * width, so

2 * length + 2 * width

Now we see both terms have a common factor, 2, which the Distributive Property of multiplication over addition tells us may be factored out:

2 * (length + width)

#5

this is what I did, which is not difficult math, but some people don't like the math as much. I really liked that you explained the math though. math is my favorite. :slight_smile:


#6

so never really challenge themselves. I used to tutor HS math and really had to battle with some learners to get them over their preconceived wall. Once they discovered that math is fun, their grades shot upward to a new high and they were away, solving things on their own and understanding new concepts. Today's society is very science oriented and without math, we have no language to speak in that is common to all sciences.


#7

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