19/33 : Your method failed when sideLength was 0 where it returned NaN instead of 0


#1

Can't figure out what is wrong.

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.sideLenght*this.sideLenght
};
var p = square.calcPerimeter();
var a = square.calcArea();


#2

return this.sideLenght*this.sideLenght 
                   ^

I believe you misspelled length there.


#3

have the same error whats the problem


#4

Helped me too, thanks.


#5

anyone who has this in the future, check your caps/non spelling. I forgot the camel-case on one :stuck_out_tongue:


#6

adkgaskjghskdfg argh it is simultaneously infuriating and hilarious that I made this error


#7

My solution is: reset code and write the code as follow, please notice the indentation, please leave 1 space for the * notation at its both side. Does my solution help you?
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();