9. Functions With Two Parameters. HELP!


#1

I am having trouble with this lesson. I can't figure out how to set length and width to a certain number. Anyone help me? this is the code I've done so far.

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


#2

You have given your parameters a specific value you should leave them as (length, width) { after calling the function, remember parameters are the variables you want to be able to change.

Now you must call and print the function like this
console.log(perimeterBox(1,1));

Also it does not matter what number you put inside.

Hope i have helped :smile:


#3

THANK YOU SOO MUCH!!! I couldn't figure that one out


#4

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


#5

What am I missing here?


#6

Seems like you misspelled "length" as your parameter name.


#7

Damn it! That typo put me out all day. Thanks for the spellcheck, Haxor789


#8

What is wrong here?

var perimeterBox = function(length === 21,width === 105)
return length + length + width + width;
print console.log(perimeterBox(55,60));


#9

parameters are just variables so no === 21 needed here:

var perimeterBox = function(length === 21,width === 105)
var perimeterBox = function(length,width) // <-- fixed

also you need to add {} around what you suppose to belong to the function. The way they get their values is by the function call so by

perimeterBox(55,60)

you tell that length is 55 and width is 60 so to say the first value is assigned to the first parameter aso.

and last but not least print is python from what I know so just use console.log and delete the print.


#10

If anybody is stumped on this part check spelling. Your returned function should look something like this.
(Read directions closely as well)

// Write your function starting on line 3

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


#11

Ok I am seeing the correct code and have it working (Thanks to you guys) but still cannot wrap my head around how it works!


#12

Option 1;

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

Option 2:

// Write your function starting on line 3

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


#13

SO STUCK! please help! I have,

// Write your function starting on line 3

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


#14

var perimeterBox = function(length, width); <--- get rid of ;
{
return length + length + width + width;
} <--- include a ; here at the end of the function

When you call the function, don't include the console.log part. You should write:
perimeterBox(2, 2);


#15

cant figure out wats wrong here

code :-
var perimeterBox =function (len , wid)
{
console.log(len + len + wid + wid );
};
perimeterBox(1,1);

output :-
4
4

error :-
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.


#16

var perimeterBox = function(length, width) {
return (length + width) * 2;
};
perimeterBox(3,9);


#17

my code

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

and its saying that 'length' is undefined how do I fix this


#18

return length + legnth + width + width;

there's a typo in the second use of length in this statement. Also if you get this kind of error you can mark the word and if they are written correctly all other instances that are written alike should be highlighted.


#19

I feel like coding is more fun than any game I could imagine. I love codecademy. I used to use a website called khan academy. But codecademy teaches many languages, web developer skills, and API's. I just love codecademy. :grinning::smiley::smile::grinning::smiley::smile::grinning::smiley::smile:


#20

I have a problem, when should we use
perimeterBox(3,9); and console.log(perimeterBox(3,9)); ?
They return the same value, right?
Also, when should we use print( ); ?