19. More Kinds of Methods


#1


Oops, try again. Your method failed when sideLength was 0 where it returned NaN instead of 0

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


#2

here:

var square.calcArea = function()

calcArea is a method, not a variable, remove the var keyword


#3

It's giving me back a same message


#4

Ok, with the var the message is:

Oops, try again. There was a problem with your syntax.


#5

can i see an updated version of your code?


#6

Sure:


#7

seems fine, try it in firefox? If that is not working, copy paste your code to the forum so i can run it (which i can't do from an image)


#8

Still the same message:

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

#9

this line:

return this.sideLength * this.sideLenght;

you misspelled sideLength.


#10

@stetim94 what tool you are using for a debagging and how?


#11

for the first one i used jsbin, the second i simply debugged in the codecademy lesson.


#12

Thans. That was a problem.

Thank you!


#13