32 Customizing Constructors - JK Rowling instead of JRR Tolkien SOLVED


I've scoured the forums and it might just be a typo, or my first encounter with a bug, but
the console keeps logging "J.K.Rowling" and should log "J.R.R.Tolkien", I think.

The code is down here. I only wrote the last line.
Should I use a return statement, or a console.log to get "J.R.R.Tolkien" on the screen?
Or am I just not seeing things right. I just don't get it.
Thanks for your help in advance.

PS I also get the error message: "make sure the authors name is J.R.R.Tolkien by passing it as the first argument in your book constructor." I did of course, but that didn't work because in the constructor the pages property is first.

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


Did you log the thehobbit_ author? try:

console.log(the_hobbit, author);


Whoa you're fast! Thanks!

I just did and yeah it does log "J.R.R.Tolkien" to the console now,
but I still get the same error saying my code is wrong:
"make sure that the hobbit's author is J.R.R.Tolkien by passing it as the first argument to the book constructor"
.. and so, I can't click "next" :wink:



var the_hobbit = new Book(320, "J.R.R. Tolkien");

So I added space between J.R.R. and Tolkien.


That's it! Thanks Denys!
Nice. But if you don't mind me asking: how did you know a space might be or is the solution?
Was it an educated guess, or you know there should be a space there, for .. reasons.


I've tried your code and compare with mine. My advice: always use the same strings as instruction says (copy and paste).


I see. In the instructions they have a space there. Excellent observation.
I'll follow the instructions more precise from now on. Thanks again.


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