19. More kind of methods


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


What wrong in this code?


Your object has only one attribute called sideLength.

Problem is in your calcArea method. Value of this.sidelength is simply undefined.

Remember that JavaScript is case sensitive.


Do you see a problem now? :smile:


Hey @digitalplayer55798! First off try to organize your code by selecting over it and hitting CTRL + K on your keyboard. Secondly the simple problem is that

when you initalized it you made it camel CASE whitch is what your suppose to do


But then when you called it in the Calc Area you didnt camel case that. Just camel Case that:

Hope it helped if it didnt! Pls resopond saying so!


Thanks Buddy! :grin: I will double check my code here after!


Thanks, funny I did the same mistake :sweat: