More Kinds of Methods 19/33


#1

why can't we use
- return this.sideLength*2;


#2

@ankurlvv
Please present the full code you are using...


#3

You are about to compute for a square. so you should use

-return this.sideLength * this.sideLength;


#4

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


#5

@leonhard_wettengmx_n my bad, srry i got it.

@jesehl @edwinisawesome i don't what i was thinking, thanks .


#6

Could use Math.pow too, right?
Math.pow(2,4); // gives 16, so:
Math.pow(this.sideLenght, this.sideLenght);