Function with two parameters. please help


#1

var parimeterBox = function(length,width) {

return length + length + width + width;

console.log(length, width)}

parimeterBox (5,6)

22 comes up in the log which is the correct answer but it keep saying "Did you define a perimeterBox function?"


#2

@nabster12,

Have a close look at

parimeterBox


#3

I also have another question.

// Write your function starting on line 3

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

perimeterBox(2,3);

How is it that perimeterBox(2,3); prints 10 in the console? I thought this wouldn't show 10 in the console because of the return keyword and also because there is no console.log.

Would the correct way be to write: console.log(perimeterBox(2,3));


#4

@darivu,
Your assumption

Would the correct way be to write: console.log(perimeterBox(2,3));

is correct.

Try using your code like

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

console.log( perimeterBox(2,3) );
console.log("== End of my code ==");
console.log("==All that follows is the code-checker ==");

#5

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


#6

@pardes5
That wouldn't work because you have

PARIMETERBOX as the variable,

and are calling console.log on PERIMETERBOX


#7

var parimeterBox = function(length,width){
return length*2 + width*2;
}

console.log(perimeterBox(2,3));

this will work now because i made a mistake in the previous code by adding perimeters where i initialised them.
but i got it work now.


#8

No its because you've spelt perimeter twice differently.

They're spelt differently and it won't console.log the correct thing you want it to.


#9

i got your point but this code worked lollz ... you can try it and see it will pass you to the next section. despite misspelt words


#10

Yes and it shouldn't do because it's wrong.

Look here

http://jsbin.com/rogepiyodo/edit?html,js,console,output

thats not giving the correct output is it?


#11

yes i got that... I am not saying that my code should work but I am too surprised how this code with error does not fail to compile. if you paste my code in code academy panel you will get my point. but i thank you for mentioning my mistake