19.) Failed When sideLength was 0


#1

So my error message is failed when sideLength was 0 wehre it returned NaN instead of 0...not sure what to do in my code to correct it honestly. Do I need some type of if/else to fix it? Seem unlikely though for this particular lesson...


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


#2

uh lots of peeps also have these problems, same here XD

Ok well check the capitalization of sidelength, it should be "sideLength" not "sidelength"

rmb camel code??


#3

Man second lesson in a row that a grammar error gets me haha thanks man! If i get to the lesson your on I will try and help you out as well :smiley:


#4

No worries man :smiley:


#5

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