Need help! Object 18


#1

var rectangle = new Object();
rectangle.height = 3;
rectangle.setHeight = setHeight;
rectangle.width = 4;
rectangle.setWidth = setWidth;

// 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);

I keep getting the error message
Oops, try again. It looks like you have an error in your code. Here's the message: ReferenceError: setHeight is not defined


#2

@cs75,

var rectangle = new Object();
rectangle.height = 3;
//rectangle.setHeight = setHeight;
rectangle.width = 4;
//rectangle.setWidth = setWidth;

// 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
console.log( rectangle );
rectangle.setHeight(6);
rectangle.setWidth(8);
console.log( rectangle );