Logical operators, HELP


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;
case 'a': 
     if(user==='a'&& answer===1) {
    console.log("Exellent work!");
    console.log("Do more exercise if you want to.");

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


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


Do you mean like this:

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

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


I mean right here.

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


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