Javascript function prints out NaN -
When I do console.log (square.area), this code returns NaN; And not 36? var calcArea1 = function () {this.area = this.sideLength * this.sidelength; }; Var class = new object (); Square.sideLength = 6; Square.area = 0; Square.changeArea = calcArea1; Square.changeArea (); Console.log (square.area); Your function has a typo: Var calcArea1 = function () {this.area = this.sideLength * this.sideLength; }; // ^^ The javascript is case-sensitive so the upper and lower case names are considered different. Because this.sidelength will be undefined in this case, when you try to use it, it will be sent to NaN (non-A- Number) will be produced (like expanding it here).