Functions with 2 parameters


Oops, try again. It looks like your perimeterBox function doesn't return the correct perimeter (4) for a width of 1 and a length of 1.

Also, the output says:

var perimeterBox = function (length, width) {
    console.log((length*2) +(width*2));


You need to pass second parameter!


Suppose I made a function that prints multiplication of two numbers..

var multi = function (num1 , num2) {
    console.log(num1 * num2);

Now we defined a function..
Now how to use our function?
To use our function.. we call it..
How to call?
We put name of function and put Exact same number of values inside it (inside the parentheses) separated by commas, that it needs.
As our example function needs two values!


It will print : 6


So is this correct?

var perimeterBox = function (length, width) {
console.log((length * 2) + (width * 2));


Try to execute by your own and tell me :slight_smile:


Didn't work.



Oh one more thing ,instead printing things, Function can return values too..

Like printing function will be like this..

var printFunc = function() {
    console.log(print something);

Function can return values using return keyword..

var returnFunc = function() {
    return something;

Try using return instead of console.log() ?


Yep, it worked. ;D
Thanks a lot!


Hey I strongly suggest to read the instruction!
If you read the instruction of this exercise it mentions to return value(i.e is parameter) not print!

so do read instructions of exercise !

(from next sections):slight_smile:


They want you to use return not console.log to output the sum. As such:

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

perimeterBox(2, 4);