24. Constructors With Methods


function Rectangle(height, width) {
this.height = height;
this.width = width;
this.calcArea = function() {
return this.height * this.width;
// put our perimeter function here!
this.calcParimeter = function() {
return 2 * this.height + 2 * this.width

var rex = new Rectangle(7,3);
var area = rex.calcArea();
var perimeter = rex.calcPerimeter();

Hi guys whenever I type this in I get a response saying "When the computer tried to call calcPerimeter of a Rectangle object, the following error was thrown: TypeError: rec_test.calcPerimeter is not a function

so what am I doing wrong?



Have close look at



Hint, hint -- look at how you spell perimeter


I didn't see that! I have been stuck for WEEKS just because of that same problem!!!


whene you create the second method you type:

this.P**a**rimeter = function(){}....

at the very end you try to call a methdo with the name rex.calcPerimeter(); which obviously doesnt exists!
So you either change this.Parimeter or rex.Perimeter()!! your choice!