# 18/33 Says to set rectangle.newWidth as 8... But i have

#1

Here is my code... Please point out my mistake.

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.newWidth = 8;
rectangle.newHight = 6;

#2

add " this at lines 5 and 8 otherwise i see nothing wrong

#3

this is right 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;
};

rectangle.setWidth(8);
rectangle.setHeight(6);

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

#4

Use the method 'setHeight' and 'setWidth' to change the height and width of the rectangle like this by passing the parameter 8:

``````rectangle.setWidth(8);
rectangle.setHeight(6);``````

#5

Like me, you spelled Height wrong: It's Height, not Hight...
Very confusing.

#6

Hi everyone

i think my code is right but it keeps showing this error "Oops, try again. Make sure to set rectangle's width to 8!**"

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

any ideas?

thanks in advanced

#7

You probably figured this out already, but for the setWidth method I think you need to set:
"this.width = newWidth;"
instead of:
"this.setWidth = newWidth;"