24. Constructors with Methods


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!
      return this. 2*height + this. 2*width;

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


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


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