19. More kinds of methods



Error: Unexpected token ,


var square = new Object();
square.sideLength = 6;
square.calcPerimeter = function() {
  return this.sideLength * 4;
// help us define an area method here
var square.calcArea = function() {
    return this.sideLenth * this.sideLength;
var p = square.calcPerimeter();
var a = square.calcArea();


Your code shouldn't throw that error @feephill. Just try it again and see what happens.

Barry Allen


You shouldn't use var keyword here.

square.calcArea = function() {...}


Okay, I did that. Now it's still throwing me the same error. :confused:


I've already been doing that for awhile now just looking for the error. Thanks anyway though, defeat Dr. Wells safely!


Here, you mispelled Length you wrote Lenth.

Your code should work after correcting that :grin:


Thanks, it works now.


You're super welcome! :grin:

If that was the answer you were looking for feel free to click the solution button below my reply. :smile:


it should be

square.calcArea = function(){...};

and not

var square.calcArea = function(){...};


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