5. Logical Errors-HELP


SyntaxError: Unexpected keyword 'else'

var user = prompt("What do you want to do tomorrow?").toUpperCase();
switch (user) {
    case 'Eat':
        var Eat = prompt("Would you like to grab dinner with me? (Yes or No)").toLowerCase();
        var Place = prompt("Would you like to go to Shabu House with me? (Yes or No)").toLowerCase;
        if (Eat === 'Yes' && Place === 'Yes') {
        console.log("Great! I love Shabu!!!!");
        else {
            console.log("Yeah I've been going out too much anyways.");
    case 'Workout':
        var Workout = prompt("Do you like working out? (Yes or No)").toLowerCase();
        var Food = prompt("Maybe we can grab a protein shake then? (Yes or No)").toLowerCase();
        if (Workout === 'yes' || Food === 'yes'); {
        console.log("Good for you forgetting your fitness on");
        else {
            console.log("Yeah i feel too lazy to work out too");
        console.log("We can always just take our time to decide.");


Your case wouldn''t work because the function .toUpperCase(); converts all letters into uppercase and your case has only E as a capital. The string in your case statement should be

And the else problem is here the break statement should be outside of the bracket. :slight_smile:


Hi and this if statement remove the ; after the closing )

if (Workout === 'yes' || Food === 'yes'); <--


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.