19/33?


#1

var square = new Object();
square.sideLength = 6;
square.calcPerimeter = function() {
return this.sideLength * 4;
};
square.calcArea = function () {
return this.sideLength * this.sideLength;
};
var p = square.calcPerimeter();
var a = square.calcArea();

My code works fine, but i want to know why we declared two variales named p and a . And also i tried calling the functions but they dont seem to work.
square.calcArea(10); doesnt give me any result. Help .!


#2

In order to recieve outpur you must call it on an object.


#3

When creating the functions there are no parameter place holders in the parenthesis, so these functions simply work with existing values in the sideLength property.