24/ 13 not passing (solved)


#1

Hi,

when I try to save and submit my code it says:

Oops, try again. 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

This is the code I used:

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 * this.heigth + 2 * this.width;
  };
}

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

Anyone knows what is wrong?
Thanks!


#2

I already found a solution with formulating the method like this:

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

#3

Although you have corrected it .The problem was not the way of computation but an error here


#4

A typpo as always...
Thank you for pointing it out!