"Make Your Own Method"


#1


Hey guys, I'm trying to figure out how to fix this error! I'm not very good at understanding "this", but I thought I did it correctly. Any help would be of great help thanks!


https://www.codecademy.com/courses/spencer-sandbox/2/6?curriculum_id=506324b3a7dffd00020bf661


Oops, try again. Make sure to set rectangle's width to 8!


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;
};
// help by finishing this method
rectangle.setWidth = function (newWidth) {
    this.witdth = newWidth;
};
  

// here change the width to 8 and height to 6 using our new methods
rectangle.setHeight(6); 
rectangle.setWidth(8);


#2

HI this line

this.witdth = newWidth;

you wrote witdth instead of width


#3

I feel so silly, thanks for the help!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.