4. Switch


#1

Hi,

https://www.codecademy.com/courses/javascript-beginner-en-ZA2rb/0/4?curriculum_id=506324b3a7dffd00020bf661#

I have written this code right, but when it asks:"What is your name?" and I write on the field: Aamu, it answers:"I don't know you yet, but soon I do!". So it goes to default, even though it should recognize that name, because it is one example case. It should answer:""What a beautiful morning, Aamu!"

I wonder, what is wrong with it?

var user = prompt("What is your name?").toUpperCase();
switch(user) {
    case 'Maria':
       console.log("Hey, sister!");
       break;
    case 'Jenni':
       console.log("Nice name, Jenni!");
       break;
    case 'Aamu':
        console.log("What a beautiful morning, Aamu!");
        break;
    case 'Emma':
        console.log("Well, hello hello, Emma!");
        break;
    case 'Leo':
        console.log("Hello, Leo the Lion!");
        break;
    case 'Onni':
        console.log("Good luck, Onni!");
        break;
    case 'Oliver':
        console.log("Hi hi, Oliver!");
        break;
    default:
        console.log("I don't know you yet, but soon I do!");
}

#2

@mariamariiia,
You are using the toUpperCase() Method
causing the user variable to contain a all-uppercase String Value

So using a case-clause like "Maria" is useless....