0

I am trying to create an object in javascript that has an object inside of it and I am getting the following error:

Uncaught SyntaxError: Unexpected token ILLEGAL

This is my code

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!"} 
};
1

1 Answer 1

2

If you take this code and format it, the error is more obvious:

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

You can't use a newline in the middle of a string

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks I tried to do javascript:alert(motivateEN.0.0); but returns an error?
@Jake To access numeric properties, you'll have to use bracket notation -- motivateEN[0][0]. Numbers aren't on their own valid identifiers, which is what dot notation expects.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.