Coding my own adventure


I keep getting an error in my code saying "unexpected token break", I also get a message saying I need to use && or something like that. tried multiple ways and still do not understand why it is not working.

var user = prompt("Where are you going?").toLowerCase();
switch(user) {

    case 'chicago':
        console.log("I hear that it is very windy there.");
    case 'los angeles':
        console.log("Oh the city of angels!");
    case 'portland':
        console.log("I also live there so I should know.");
        console.log("I actually have never been.");
    }        console.log("Better be pepared for all weather types!");
    case 'new york':
        console.log("Try not to get mugged!!");
    console.log("Must be a small town because I have never heard of it / before");


Now after removing the random break it is telling me that portland is not defined.


And the error is quite right to. You said that if Portland is true then run this black of code else run this block of code. When you put Portland into your if statement then it treated it like a boolean when really you want Portland to be a string.

Remember to keep the break removed as well.


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