5 logical operators


#1

var user = prompt("What's your fave subject").toUpperCase();
switch(user){
case 'history':
var which = prompt("U.S or World history")
if( which === "U.S"){
console.log("Thats my fave too")}
else{
console.log("Any history is good")
break;
case 'math':
console.log("Ew!")
break;
case 'Science':
console.log("Well different strokes for different folks")
break;
default:
console.log("any class is a good class")
}

it says SyntaxError: Unexpected token case


#2

try putting ; after each console.log


#3

it still says unexpected token case


#4

You don't close this else statement.


#5

var user = prompt("What's your fave subject").toUpperCase();
switch(user){
case 'history':
var which = prompt("U.S" || "World history");
if( which === "U.S"){
console.log("Thats my fave too");
}
else
{
console.log("Any history is good");
break;
case 'math':
console.log("Ew!");
break;
case 'Science':
console.log("Well different strokes for different folks");
break;
default:
console.log("any class is a good class");
}

this is what I have now


#6

how would i close it


#7

with a closing curly brace, }, before your break; line
It should look like:

else { 
console.log("Any history is good")
}
break;

#8

i figured it out thanks.


#9

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