5. Logical operators need help!


#1



what is wrong with this code
the error is SyntaxError: Expected ')'

Replace this line with your code. 
var user = prompt ("what is heaviest 1 kilogram steel or 1 kilogram straw ? ").toLowerCase();

switch(user){
case '1 kilogram steel':
 var stupid = prompt("are you stupid? YES or NO".toUpperCase();
    if ( stupid==="YES"||  stupid === "NO"){
        console.log("wrong!  you know what they say think twice and decide once");
}     
else{   
console.log("i know you are stupid but I just asked so you could know if you can get any dumber ");
}

break;

case '1 kilogram straw':
console.log(" are you stupid? , btw you don`t have to answer that because we all know  ");
break;

case'they are same ':
    console.log("you are smarter than i expected");
    break;
    
  case 'same':
    console.log("you are smarter than i expected");
    break;
    
    default:
console.log("sorry but your answer is not relevent");
break;
    }


#2

You need to add a parentheses on this line to close your prompt,


#3

what do you mean? haven`t I closed prompt


#4

You need an extra parentheses after your .toLowerCase() method to close your prompt()


#5

Nope! didn`t work but thanks for trying


#6

I have tested your code myself, if you close your prompt like this,

var user = prompt ("what is heaviest 1 kilogram steel or 1 kilogram straw ? ").toLowerCase());

Your code will work. :slight_smile:


#7

an then i got an new error saying SyntaxError: Expected ';'


#8

If you write exactly as it is above you shouldn't receive that error


#10

see here is the code
and I stil get error

var user = prompt ("what is heaviest 1 kilogram steel or 1 kilogram straw ? ").toLowerCase());
switch(user){
case '1 kilogram steel':
var stupid = prompt("are you stupid? YES or NO".toUpperCase();
if ( stupid==="YES"|| stupid==="NO"){
console.log("wrong! you know what they say think twice and decide once");
}
else{
console.log("i know you are stupid but I just asked so you could know if you can get any dumber ");
}
break;
case '1 kilogram straw':
console.log(" are you stupid? , btw you don`t have to answer that because we all know ");
break;

case'they are same ':
console.log("you are smarter than i expected");
break;
case 'same':
console.log("you are smarter than i expected");
break;
default:
console.log("sorry but your answer is not relevent");
break;
}


#11

One of your prompt's was still incorrect try writing them like this,

var user = prompt ("what is heaviest 1 kilogram steel or 1 kilogram straw ? ".toLowerCase());
switch(user){
case '1 kilogram steel':
var stupid = prompt("are you stupid? YES or NO".toUpperCase());

#12

ok, I think i gott it now and thanks for the help I appricate it


#13

You're welcome. :grin:


#14

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