Why were the functions set equal to one another?


#1

var rectangle = new Object();
rectangle.height = 3;
rectangle.width = 4;
// here is our method to set the height
rectangle.setHeight = function (newHeight) {
this.height = newHeight;
};
rectangle.setWidth = function (newWidth) {
this.width = newWidth;
};
// help by finishing this method
rectangle.setWidth = rectangle.setWidth
rectangle.setHeight = rectangle.setHeight
// here change the width to 8 and height to 6 using our new methods
rectangle.setWidth(8);
rectangle.setHeight(6);

not sure why we set rectangle.setHeight/setWidth equal to one another...kind of confused on why that is


#2

I don't really see any sense in doing that... maybe I don't know enough. Does it ask you to have those 2 lines?


#3

Wait, why did you even set them equal to themselves? It's unnecessary xD

You were supposed to put the

rectangle.setWidth = function (newWidth) {
      this.width = newWidth;
};

under the // help by finishing this method

It let you through because you did the method right, but you don't need the

rectangle.setWidth = rectangle.setWidth
rectangle.setHeight = rectangle.setHeight

#4

wow ok yeah. I was wondering why the rectangle.setWidth was there makes so much sense. Thanks!