18. Make Your Own Method please help


#1



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


It keeps saying that my width is undefined and I am not sure why it looks defined to me
Please help :confounded:


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 =width;
  rectangle.setWidth(8);
rectangle.setHeight(6);
// here change the width to 8 and height to 6 using our new methods


#2

This post was flagged by the community and is temporarily hidden.


#3

I changed it and now it says there is a syntax problem
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 (width) {
this.width = newWidth;
rectangle.setWidth =width;
rectangle.setWidth(8);
rectangle.setHeight(6);


#4

This post was flagged by the community and is temporarily hidden.


#5

This post was flagged by the community and is temporarily hidden.


#6

I got it small errors and I just needed to declare it thx


#7

This post was flagged by the community and is temporarily hidden.


#8

I have a problem with this thing


#9

this is my code.

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.Width = newWidth;

}

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

for (var a in rectangle) {

console.log(rectangle[a]);

};
its not working


#10

This post was flagged by the community and is temporarily hidden.