Logical operators, HELP


#1


Can anyone take a look at my code? I don't know why it only print default on the last line, and I have already revised the case 'a' and case 'b' multiple times. Thanks a lot.


Replace this line with your code. 

var user = prompt("What is your grad of math?" ).toUpperCase();
var answer = prompt("How many times have taken math? Please input a number!");
 var answer = 1;
 var answer2 = 2;
    
switch(user){
    
case 'a': 
     if(user==='a'&& answer===1) {
    console.log("Exellent work!");
    }
    else{
    console.log("Do more exercise if you want to.");
    }
break;

case 'b': 
    if (user==='b'&& answer===1 || answer2===2)
    console.log("Good job! You can practice more.");
break;
case 'c':
    console.log("Not bad!");
break;
default:
    console.log("You can do better!");
}


#2

After the user variable, you convert it to uppercase. You need to keep these patterns.


#3

Do you mean like this:

if(user.toUpperCase()==='a' && answer===1)
or
if(user==='a'.toUpperCase() && answer===1)

They both are not working. Can you please give me a example? thanks


#4

I mean right here.
The

makes whatever the user inputs uppercase, but when you're establishing the cases to your switch, they're lowercase.


#5

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