13/24 Constructors With Methods - ReferenceError: rectangle is not defined


#1

This is my code: ( THE MESSAGE I AM GETTING IS :"ReferenceError: rectangle is not defined") PLEASE HELP

function Rectangle(height, width) {
this.height = height;
this.width = width;

this.calcArea = function() {
return this.height * this.width;
};
// put our perimeter function here!
rectangle.calcPerimeter = function (){
return (2*this.height) + (2* this.width);
}
}

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

THANKS IN ADVANCE
A


#2

On this page, press Ctrl+F and type "rectangle", that should cause your browser to highlight all occurrences of that text and let you better see where and how you are using that name(s).


#3

I've worked it out. As always is something unexpected and "minor".
This proves to me how careful you attentive i need to be while coding!


#4

Hi. Thanks for your answer. What that would be on the mac? "CTRL + F "or "CMD +F" did nothing.
Mistake in the code was in the wording!!Thanks. A


#5

I wouldn't know. But you certainly should look up how to search for text in a browser. Super useful when reading documentation for example.. I even use search for navigating around in my code editor.


#6

Thank you for your suggestion. I will look it up. thanks :slightly_smiling:


#7

in perimeter function instead of giving "rectangle.calcPerimeter" you should go with "this.calcPerimeter"