More kinds of methods


#1

...i can't figure out what's wrong with the second method here, returns NaN

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();

#2

Did you mean to write, sideLength? JavaScript is case sensitive.


#3

Thanks for pointing that out :slight_smile:


#4

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