未捕获的语法错误:javascript对象上出现意外的标记ILLEGAL

Uncaught SyntaxError: Unexpected token ILLEGAL on javascript objects

本文关键字:意外 ILLEGAL javascript 语法 错误 对象      更新时间:2023-09-26

我试图用javascript创建一个对象,其中包含一个对象。我得到了以下错误:

Uncaught SyntaxError: Unexpected token ILLEGAL

这是我的代码

var motivateEN = {
    0 : {0: "{name}, keep studying this lesson for a better score.", 1: "Bad luck {name}, keep studying this lesson to improve.
"},
    50:{0: "Practice makes perfect {name}, try this lesson again.",1:"Not bad, but better luck next time {name}!",2:"Well done {name}, you’re on the right track!"},
    85:{0:"Congratulations {name}, lesson complete!",1:"Woohoo, lesson complete {name}!",2:"Awesome stuff {name}! Keep it up!",3:"Great skills! Well done {name}!
"},
    100:{0: "Perfect {name}! Keep up the good work!",1:"Congratulations {name}, you got a perfect score!"} 
};

如果你把这个代码格式化,错误会更明显:

var motivateEN = {
    0: {
        0: "{name}, keep studying this lesson for a better score.",
        1: "Bad luck {name}, keep studying this lesson to improve.
        "},
...

不能在字符串的中间使用换行符