Use methods with constructors


#1



https://www.codecademy.com/en/courses/spencer-sandbox/3/5?curriculum_id=506324b3a7dffd00020bf661#


It says that "SyntaxError: Unexpected end of input"
What's wrong with my 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.height + this.width) * 2;
};

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


#2

Hi you didn't close the Rectangle constructor, with }

function Rectangle(height, width) { //open Rectangle
    ....
}//close Rectangle

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.