More Kinds of Methods


So I double checked everything but I get this error message. Oops, try again. Your method failed when sideLength was 0 where it returned NaN instead of 0. Here is my code. PLZ HELP!!!

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


Your sideLength's in calcArea have lower case 'L's which points to a yet un initialized property making calcArea actually calculate 'undefined' * 'undefined'.


thanks. I spent 20 minutes trying to figure this out!


It happens. ALL THE TIME. Lol, its the worst because the writer of the code is the least likely person to see it. Keep it up!


I've just started programming 17 days ago and I have been practicing everyday. It's amazing how much knowledge you can obtain in a couple weeks!


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