Please help with this code. Cant find what the problem is... 18/33


#1

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


#2

Everything seems correct ?


#3

yes... i tried again after reseting the code...it worked fine this time:)


#4

Well then, Good luck! :smile:


#5

thanks @udayk8139
can you help me here though?
// 3 lines required to make harry_potter
var harry_potter = new Object();
harry_potter.pages = 350;
harry_potter.author = "J.K. Rowling";

// A custom constructor for book
function Book (pages, author) {
this.pages = pages;
this.author = author;
}

// Use our new constructor to make the_hobbit in one line
var the_hobbit = new Book (320, "J.R.R Tolkien");

this is the error message i am getting:
Oops, try again. Make sure that the_hobbit's author is J.R.R. Tolkien by passing it as the first argument to the Book constructor.

and even if i pass author name first..the code doesnt work


#6

Read the comments, this error somehow happened to me even though my script is 100% correct, so the problem here is the the codecademy is very case sensitive o.O

var harry_potter = new Object();
harry_potter.pages = 350;
harry_potter.author = "J.K. Rowling";

// A custom constructor for book
function Book (pages, author) {
this.pages = pages;
this.author = author;
}

// Use our new constructor to make the_hobbit in one line
var the_hobbit = new Book (320, "J.R.R Tolkien"); // Here just put the name from the lesson bar, (copy and paste) cause somehow I did the same and I passed xD IDK why that happened. :confused:

#7

its way too sensitive... anyways.. it worked.. tried again:D