Please help! Why isn't this code working?


#1

Introduction to Object I
Make Your Own Method

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;

Thanks


#2

here:

rectangle.setHeight = 6;
rectangle.setWidth = 8;

you should call the setHeight and setWidth methods, to call methods do: methodName(), supply arguments between the parantheses if the method has parameters


#3

That was exactly my answer: rectangle.setHeight = 6; rectangle.setWidth = 8;

I cannot see why stil showing me the same 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) {
this.width = newWidth;
};

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


#4

Sorry :wink:

I saw the mistake that i have.

Thanks


#5