18. Make your own method


Help: I keep getting an error stating that I have not changed the setWidth to 8. If you look in my code it has rectangle.setWidth(8); I am not sure what I am missing. Thank you in advance.

Make your method: https://www.codecademy.com/en/courses/spencer-sandbox/2/6?curriculum_id=506324b3a7dffd00020bf661#

Error message: 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){
rectangle.setWidth = newWidth;

// here change the width to 8 and height to 6 using our new methods


ise the this. operator in this function to set the width,


Thank you! I was able to get through to the next lesson.


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