Keep getting Unexpected token error


#1



var user = prompt("Will you fight?").toUpperCase();
switch(user){
case: 'FIGHT'
var able = prompt("Are you ready to throw it out, boy").toUpperCase()
if(able==='YES' || able==='NO'){
console.log("Let's ride");
} else{
console.log("That's what I thought");
}
break;
case: 'DUCK'
var real = prompt("This is what you want to do with your life?").toUpperCase();
if(real==='YES' || real==='NO'){
console.log("That's fine");
}else{
console.log("Okay then, boy");
}
break;
case: 'LAME'
var common = prompt("Will you give it your best perfromance, young grasshopper?").toUpperCase();
if(common==='YES'|| common==='NO'){
console.log("This is great and we will do the best");
}else{
console.log("Well then we can't faciliate that");
}
break;
default:
console.log("Sorry this is choice is invalid");
};


Replace this line with your code.


Unexpected token error keeps coming up. Can anyone please help?
Unexpected token error keeps coming up. Can anyone please help?
#2

Please paste in your code


#3

Hi this part

case: 'FIGHT'

should be like that

case 'FIGHT' : 
#do something 
break
case 'Duck':
#do somthing
break

the collon go after


#4

You need to leave a space between the values
(able === 'YES' || able === 'NO')

Missing a semi colon


#5

Thank you sooo much! I've been stuck at this issue for the past 30 minutes. Thanks for the swift reply!


#6



var user = prompt("Will you fight?").toUpperCase();
switch(user){
case: 'FIGHT'
    var able = prompt("Are you ready to throw it out, boy").toUpperCase()
    if(able==='YES' || able==='NO'){
        console.log("Let's ride");
    } else{
        console.log("That's what I thought");
    }
         break;
case: 'DUCK'
    var real = prompt("This is what you want to do with your life?").toUpperCase();
    if(real==='YES' || real==='NO'){
        console.log("That's fine");
    }else{
        console.log("Okay then, boy");
    }
        break;
case: 'LAME'
    var common = prompt("Will you give it your best perfromance, young grasshopper?").toUpperCase();
    if(common==='YES'|| common==='NO'){
        console.log("This is great and we will do the best");
    }else{
        console.log("Well then we can't faciliate that");
    }
        break;
default:
    console.log("Sorry this is choice is invalid");
};

Continuing the discussion from Keep getting Unexpected token error:


#7

your case statements have the colon at the wrong place, you have the colons after case:

case: 'LAME'

they should be at the end:

case 'LAME':

This goes for all case statements