24/13 What wrong with this code?


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

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

who know, what wrong with this code?


Hey @devjumper97114! You just mispeled hieght here(i put it in bold):

Its spelled height :laughing:

Hope this helped!


If you would like to learn about troubleshooting code that is not doing what you think it should then the first thing to do is get your program to tell you what it's doing.

You can play around in places like https://repl.it/.

Try adding this to the end of your code and see what the results are:

console.log("area: ", area);
console.log("perimeter: ", perimeter);

Then, if you need more help, just post here again.