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


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



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).


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!


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


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.


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


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