Austin Hansen
Austin Hansen

Reputation: 374

Cannot find the Syntax Error for CodeCademy JavaScript Lesson 32/33

I am working on a JavaScript program of Codecademy and have a simple assignment to create a new object using the Constructor 'book'. I keep getting an error for the author but I cannot understand why.

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

Upvotes: 0

Views: 375

Answers (1)

zerkms
zerkms

Reputation: 255005

As per the error message:

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.

which means you simply lost one dot character in your code:

var the_hobbit = new Book(320, "J.R.R Tolkien") ;
                                     ^-- here should be an extra dot

Upvotes: 2

Related Questions