32. Customizing Constructors - incorrect error message



If you misspell J.R.R. Tolkien's name as your author in the new Book constructor the error message will read: "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."

That is incorrect. The first argument in the custom constructor function for Book is pages, not author. The author's name should be passed as the SECOND argument to the Book constructor. Check the spelling and try again.

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


You misspelled "Tolkein"

Its "Tolkien" and not "Tolkein"


Same issue. Error message should indicate that the name should be input as the second argument.


I have the same issue again! Was anyone able to fix the problem?


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