Lesson 4 the code works but not correct


#1

Hi!
My code looks like that:

var user = prompt("What's your name?").toUpperCase();
switch(user) {
case'Ewa':
console.log("The first woman in the world!");
break;
case'Marta':
console.log("Very nice name");
break;
case'Justyna':
console.log("Pretty name");
break;
default:
console.log("Is this name?");
}

I write "Ewa" and I got an answer "Is this name"? But this is not true. Why? It goes on to the next point but I want that this is correct. Thanks in advance for your help


#2

Here you change the answer to UPPERCASE but later your switch checks for lowercase answers:

So it is receiving 'EWA' and won't run the code.


#3

Thanks for answer but I don't understand...I gave "ToLoweCase" and the asnwer is same. What should I do so the answer will be like in my code?


#4

You made the case 'Ewa' - which is an uppercase E followed by 2 lowercase letters: w, and a. To make the case work, you need to have all of the letters the same case, then check for that version of that word in the case:

var user = prompt("What's your name?").ToUpperCase();

followed by

case 'EWA':

#5

Thanks a lot! now is all corect!:smile: