Code Your Own Adventure: 'SyntaxError: Unexpected token {'


#1



Can't find the error in my code, looked several times and I think it might have to do with missing a brace or two somewhere, but I can't find it.

https://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661#


SyntaxError: Unexpected token {


var user = prompt("Computer is asking you a question.","Computer requests your answer here.").toUpperCase();
switch(user) {
    case 'CASE1':
        console.log("You answer the computer with CASE1.");
        var c1Answer = prompt("Do you understand?","[YES/NO]").toUpperCase();
        if (c1Answer == "YES") {
            console.log("Congrats! Can you tell me, then, because...I don't understand!");
        }
        else {
            console.log("It's so easy to understand, though...");
        }
        break;
    case 'CASE2':
        console.log("You answer the computer with CASE2.");
        var c2Answer1 = prompt("DO YOU UNDERSTAND THE NUMBERS, MASON? WHAT DO THEY MEAN?","[YES/NO]").toUpperCase();
        var c2Answer2 = prompt("WHAT ARE THE NUMBERS, MASON?","[number1,number2,number3,etc.]").toUpperCase();
        if (c2Answer1 == "YES" && c2Answer2 == "4,8,15,16,23,42") {
            console.log("Don't tell me...you're LOST? DAMMIT!");
        }
        else {
            console.log("Dammit, Mason! YOU NEED TO KNOW WHAT THE NUMBERS MEAN!");
        }
        break;
    case 'CASE3':
        console.log("You answer the computer with CASE3.");
        var c3Answer1 = prompt("Guess what day it is!","What day is it?").toLowerCase();
        if (c3Answer1 == "monday") {
            console.log("Wake me up inside! \(Can't wake up\) Wake me up inside! \(Save me\) Call my name and save me from the dark");
        }
        else if (c3Answer1 == "tuesday" || c3Answer1 == "thursday") {
            console.log("That's okay. Because we are almost there, just one more step.");
        }
        else if (c3Answer1 == "wednesday") {
            console.log("HUMP DAAAAAAY!");
        }
        else if (c3Answer1 == "friday" {
            console.log("It’s Friday, Friday, gotta get down on Friday! Everybody’s lookin’ forward to the weekend, weekend, Friday, Friday, gettin’ down on Friday! Everybody’s lookin’ forward to the weekend!");
        }
        else if (c3Answer1 == "saturday") {
            console.log("I said, y'all having a good time out there? Heeey, yeah, yeah, que no pare la fiesta! Don't stop the party! Heeey, yeah, yeah, que no pare la fiesta! Don't stop the party!");
        }
        else if (c3Answer1 == "sunday") {
            console.log("BOOGITY BOOGITY BOOGITY! LET'S GO RACIN' BOYS!");
        }
        break;
    default:
        console.log("You answer the computer with "+user+".")
}


#2

this line:

else if (c3Answer1 == "friday" {

missing ) after friday" to close your if condition


#3

Thank you so much! :grin: