Problem 24/33


#1

function Rectangle(height, width) {
this.height = height;
this.width = width;
this.calcArea = function() {
return this.height * this.width;
};
// put our perimeter function here!
this.calcPerimeter = function() {
return (this.height * 2) + (this.width * 2);
};
var rex = new Rectangle(7,3);
var area = rex.calcArea();
var perimeter = rex.calcPerimeter();
can you tell me what did I do wrong ?


#2

Try this code! (Worked for me)

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

var rex = new Rectangle(7,3);
var area = rex.calcArea();
var perimeter = rex.calcPerimeter();
You don't need to put

this

after your return; you also don't need the ().:slightly_smiling:


#3

Hey !
Thanks, it works ! :slightly_smiling: