Code Your Own Adventure 2 "Switch"


#1



My code states that there is an unexpected identifier but I don't see where the problem would be.


var user = prompt("How many glasses of water do you drink per day?")

switch(user) {
    case '1':
        console.log("That is very little! You could be very dehydrated!");
        break;
    case '2':
        console.log("You need to drink more!");
        break;
    case '3':
        console.log("On the right tack but you still need more!")
        break;
    case '4':
        console.log("You need double amount.")
        break;
    case '5':
        console.log("Good enough");
        break;
    case '6':
        console.log("Almost at the recommended amount.");
        break;
    case '7'
        console.log("Healthy amount but still could use one more glass")
        break;
    case '8':
        console.log("Perfect");
        break;
    default:
        console.log("What are you talking about?");
        break;
};


#2

I restarted and it ended up working.


#3

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