32. Customizing Constructors. I dont understand why


#1

Ok, I've having a really hard time with this Introduction to Objects in general.

In this lesson in particular, I dont understand why the console reads "J.K. Rowling" after I write my new var..

code is correct, but i dont see how after I make my the_hobbit var, it gives me J.K. Rowling.

Please help me understand!

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


#2

because the_hobbit is a instance of your object? Codecademy just echoes the last variable to the console, nothing to worry about it.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.