24. the rectangle. Constructors With Methods


#1

Where is the problem???

function Rectangle(height, width) {
  this.height = height;
  this.width = width;
  this.calcArea = function() {
      return this.height * this.width;
  };
  this.calcPerimeter = function() {
      return 2*(this.heigth + this.width);
      };
};
var rex = new Rectangle(3,3);
var area = rex.calcArea();
var perimeter = rex.calcPerimeter();

it returns:
There seems to be something wrong with your calcPerimeter method! According to your code, a rectangle with sides 1 and 1 has a perimeter of NaN when it should be 4


#2

this line:

return 2*(this.heigth + this.width);

you misspelled height


#3

ough!!!!

a lot of thanks!!!


#4