More kinds of Methods Reference Error


Hello! I'm stuck on More Kinds of Methods and I am receiving the following reference error:

ReferenceError: sideLength is not defined

I'm not sure why I'm getting this error, my calcArea function looks almost identical to calcPerimeter


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 * sideLength;

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


Wait, I got it!

instead of

return this.sideLength * sideLength

it should be

return this.sideLength * this.sideLength


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