# 24/33 intro to objects

#1

'Unexpected Number', it says.

``````function Rectangle(height, width) {
this.height = height;
this.width = width;
this.calcArea = function() {
return this.height * this.width;
};
// put our perimeter function here!
function calcPerimeter(8, 4) {
return 2 * this.height * 2 * this.width

}
}

var rex = new Rectangle(7,3);
var area = rex.calcArea();
var perimeter = rex.calcPerimeter();``````

#2

Review your calcPerimeter() function. Why did you put two numbers as arguments? this method doesn't contain any paramters. It's method should calculates and returns the perimeter for a Rectangle in terms of height and width.

#3

I was providing values for the height and width variables.

#4

Alright. Here's my new code:

function Rectangle(height, width) {
this.height = height;
this.width = width;
this.calcArea = function() {
return this.height * this.width;
};
// put our perimeter function here!
function calcPerimeter (height, width) {
return 2 * this.height + 2 * this.width;
}
}

var rex = new Rectangle(7,3);
var area = rex.calcArea();
var perimeter = rex.calcPerimeter();

I tried replacing the parameters of calcPerimeter with height and width, but no go. Is there something wrong with my function syntax?

#5

you provide values here:

``var rex = new Rectangle(7,3);``

So, width = 7, height = 3. should be:

``````function calcPerimeter() {
return 2 * (this.height + this.width;
}``````

#6

With a closing parenthesis, right?

#7

With a closing parenthesis

#8

It's still not working.

#9

can i see an updated version of your full code?

#10

#11

K. here:

``````function Rectangle(height, width) {
this.height = height;
this.width = width;
this.calcArea = function() {
return this.height * this.width;
};
// put our perimeter function here!
function calcPerimeter () {
return 2 * (this.height + this.width);
}
}

var rex = new Rectangle(7,3);
var area = rex.calcArea();
var perimeter = rex.calcPerimeter();``````

#12

calcPerimeter is a method, you use function syntax.

Look at your caclArea method if you need a method syntax refresher

#14