24. Constructors with Methods


#1


24.Constructors with methods

Syntax Error:Unexpected number . Please Help!! Thanks!!

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

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


#2

the variable you want to use are this.height and this.width which you need to multiply by 2, you can't just insert the two somewhere in the middle of the variable name


#3

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