Build your own adventure 2 (4:switch case) (SyntaxError: expected expression, got end of script) PLZ HELP


#1


I am in build your own adventure 2 (4:switch)


This is the error I keep getting.
(SyntaxError: expected expression, got end of script)


var user = prompt("You are walking through the forest, and you come across a baby bear. Do you FEED IT, KILL IT, or LEAVE IT?","Type your answer here").toUpperCase();

switch (user) {
    case 'FEED IT':
     var food1 = prompt("What do you feed it BERRIES or FISH?").toUpperCase();
        if(food1 === "BERRIES") 
        {
          console.log("The bear eats the berries and starts folowing you around.");
        } 
        else 
        {
           console.log("You feed the bear the fish, but after half an hour it gets very ill and dies.");
        }
        break; 
    case 'KILL IT':
        var die = prompt("How do you want to kill the bear? GUN or KNIFE?").toUpperCase();
        if(die ==="KNIFE")
        {
            console.log("Interesting choice....Silent killing.");
        }
        else
        {
            console.log("Nice choice, far range and instant death.");
        }
        break;        
      case 'LEAVE IT':
        var leave = prompt("Do you want the bear to have a fighting chance?").toUpperCase();
        if(die ==="YES") 
        {
            console.log("You leave the bear some food and leave it to fend for itself.");
        }
        else
        {
            console.log("You are very cold-hearted.");
        }
        break;        
    
    default: 
    { console.log("I don't understand your choice. Please run the console again and choose to FEED IT, KILL IT, or LOOK FOR IT'S MOTHER?");
    }


#2

Hi you didn't close the switch statement


#3

Thank you so much! I spent so much time looking for the problem. I cant wait until I finish this course and a couple more and start using sublime text 3. There are a few plugins that help with this.


#4

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