19/33 More Kinds of Methods


#1

var square = new Object();
square.sideLength = 6;
square.calcPerimeter = function() {
return this.sideLength * 4;
};
// help us define an area method here
square.calcArea = function(){
return this.sidelength * this.sidelength;

};

var p = square.calcPerimeter();
var a = square.calcArea();

Console error is " Your method failed when sideLength was 0 where it returned NaN instead of 0 "


#2

return this.sidelength * this.sidelength;

should be:
return square.sideLength * square.sideLength ;


#3

You just have to make sure that if you are starting with "sideLength" you continue with it and not "sidelength"


#4

Capitalization matter