5. Logical Operators


I keep getting this error code: SyntaxError: Unexpected token {


var user = prompt("What is your name?").toLowerCase();
switch(user) {
    case 'Jeff':
        var hungry = prompt("Are you Hungry?, (Yes or No)").toLowerCase();
        var food = prompt("Did you bring food?, (yes or No)").toLowerCase();
        if(hungry === 'yes' && food === 'yes') {
            console.log("Let's eat!");
        } else (hungry === 'yes' && food === 'no') {
            console.log("Go get us some food!");
    case 'Ray':
        var cook = prompt("Hey Dude, Can you cook? (Yes or No)").toLowerCase();
        var have = prompt("Do have any food? (Yes or No)").toLowerCase();
        if(cook === 'yes' && have === 'yes') {
            console.log("Great! you can fix diner!");
        } else (cook === 'no' || have === 'no') {
            console.log("Thats ok I can fix something to eat");
    case 'Marcela':
        console.log("What's for dinner?");
        console.log("We starve");


Hi the else statement doesn't take any condition

if (condition) {
   #do something
else {


so you should remove the condition to all your else statement


Thank you, it worked


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