Logical Operators


#1

can someone please help me!! I have re done this code so many times and I'm getting so frustrated!!! What am I doing wrong! I keep getting the error message unexpected identifier.

var user = prompt("Are you ready to play this game?") .toUpperCase();
var city = prompt("What's your favorite city?","Type your favorite city here.");
var Philadelphia
var New York
switch(city){
case 'Philadelphia':
if(Philadelphia && New York===true){
console.log("Let's go there!");
}else{
console.log("Maybe another time.");
}
break;
case 'New York':
if(Philadelphia || New York===true){
console.log("I would love to live there!");
}else{
console.log("I like my home town better.");
}
break;
case 'Boston':
console.log("It's too cold in the winter.");
break;
default:
console.log("Every city is great in its own way!");
}
`


#2

If you run it in another interpreter you might get a more verbose error message.

Here's what nodejs says:

$ node blogsurfer47453.js 
/tmp/javascript/blogsurfer47453.js:4
var New York
        ^^^^
SyntaxError: Unexpected identifier

#3

omg THANK YOU SOOOOOO MUCH!!!!

I had to change New York to newYork


#4

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