Could someone please revise my code - I'm stuck!


#1

Hi team, I can't seem to find where I've gone wrong. It consistently returns "Syntax Error". Ignore my lame inputs!

var user = prompt("What do you want to do today? Do you want to STUDY, PLAY or WORK?").toUpperCase();

switch(user) {
case 'STUDY':
var preparation = prompt("Have you eaten breakfast? YES or NO").toUpperCase();
var focus = prompt("Are you able to stay focused? YES or NO").toUpperCase();
if (preparation == YES && focus == YES) {
console.log("Good! Study is important.");
} else if (preparation == YES || focus == YES) {
console.log("You should study, but make sure you have the right start to the day.");
} else {
console.log("study is important, but you won't be able to do it without breakfast and focus.");
}
break;

case 'PLAY':
    var confirmation = prompt("Are you sure you don't have to study? YES or NO").toUpperCase();
    var friends = prompt"(Do you have any friends that can come over and play? YES or NO").toUpperCase();
        if (confirmation == YES && friends == YES){
            console.log("Awesome! Let the play time begin!");
        } else if (confirmation == YES || friends == YES) {
            console.log("You can't really do one without the other!");
        } else {
            console.log("Play is not a good idea today.");
        }    
    break;

case 'WORK':
    var areYouSure = prompt("Are you sure you want to work today YES or NO? It's your day off!").toUpperCase();
    var catchUp = prompt("Do you things you need to catch up on? YES or NO").toUpperCase();
        if (areYouSure == YES && catchUp == YES) {
            console.log("Very well - Very diligent!");
        } else if (areYouSure == YES || catchUp == YES) {
            console.log("Very responsible of you, but I think you should reconsider.");
        } else {
            console.log("Don't be silly then! Enjoy your day off.");
        }
    break;

default:
    console.log("I really think you should be studying.");
    break;

}


#2

You forgot to put the double quotation marks around the YES in every condition of your if/else if/else statements. YES is not a boolean nor a number nor string nor nothing.

if (confirmation == "YES" && friends == "YES"){

There's a random line I took from your code and corrected. Let me know if it still doesn't work.


#3

Thank you for your reply! I have amended my code as suggested, but there seems to be another error. Can you see what it is?