Do both methods(area and perimeter) run when rex.caclPerimeter is called?


#1



Replace this line with your code. 

unction 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.height+this.width);
};
};
var rex = new Rectangle(7,3);
var area = rex.calcArea();
var perimeter = rex.calcPerimeter();




i mean when rex.calcArea(); is called do the calcPerimeter method is run along with calcArea ?


#2

Could you please paste your code? :smiley:


#3

i have edited it please see


#4

No! when you call rex.calcArea() function it'll run only run rex.calcArea() function not the other.
run it :slight_smile:

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