[英]Cannot find the Syntax Error for CodeCademy JavaScript Lesson 32/33
我正在使用Codecademy的JavaScript程序進行工作,並進行了簡單的分配,以使用構造函數“書”創建新對象。 我不斷收到作者的錯誤,但我不明白為什么。
// 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") ;
根據錯誤消息:
糟糕,再試一次。 通過將the_hobbit的作者作為第一個參數傳遞給Book構造函數,確保其是“ JRR Tolkien”。
這意味着您只是在代碼中丟失了一個點字符:
var the_hobbit = new Book(320, "J.R.R Tolkien") ;
^-- here should be an extra dot
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.