It tells me unexpected token case, any suggestions as to what to fix?


SyntaxError: Unexpected token case

Replace this line with your code. 
var user = prompt("Your dog is barking in the middle of the night and it's not letting you sleep. Do you feed him, kill him, or yell at him?").toLowerCase();

switch(user) {
    case 'feed him':
        var food = prompt("Do you have food for your dog?(yes or no)").toLowerCase();
        var hungry = prompt("Is your dog hungry?(yes or no)").toLowerCase();
        if(food === yes && hungry === yes) {
            console.log("Good job! You can now go get your beauty sleep!");
        } else {
            console.log("That's too bad! Now you can't sleep unless you try something else!");

    case 'kill him':
        var weapon = prompt("Do you have a weapon to help kill him?(yes or no)").toLowerCase();
        var guts = prompt("Do you have the guts to kill your own dog?(yes or no)").toLowerCase();
        if(weapon === yes && guts === yes) {
            console.log("Congratulations! You can now sleep in peace without your dog barking, although you'll probably serve jail time. Look on the bright side, you did get to go back to sleep! Enjoy it while you can.");
        } else {
            console.log("Guess you don't have the guts or an adequate weapon. No sleep for you!");

    case 'yell at him':
        var voice = prompt("Can you yell in a commanding and powerful voice?(yes or no)").toLowerCase();
        var obedience = prompt("Is your dog typically obedient?(yes or no)").toLowerCase();
        if(voice === yes || obedience === yes) {
            console.log("Well done! You can now get some peaceful sleep.");
        } else {
            console.log("You don't have a commanding voice AND your dog isn't obedient? Someone is out of luck tonight!");

        console.log("I didn't catch that, try again!");



if(food === yes && hungry === yes) // yes is a string value so i would write like

if(food === "yes" && hungry === "yes")

do same for the rest


here after add } bracket

else {
console.log("Guess you don't have the guts or an adequate weapon. No sleep for you!");
// here close else statement


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