The switch isn't working!?


#1

:angry: :sob: This switch isn't working as its supposed to :angry: :sob:

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

There aren't any error messages, but the switch is doing the wrong thing. It running the default case for some reason despite the input


var user = prompt('Your name is...').toUpperCase();
switch (user) {
    case 'Buster':
        console.log('Phelp\'s son?');
        break;
    case "Michael":
        console.log("Are you in the Jackson five");
        break;
    case "Monty":
        console.log("Do you code in Python?");
        break;
    case "David":
        console.log("David Livingstone I presume?");
        break;
    default:
        console.log("Good Name");
}


#2

The value you switch on has been converted to all upper case, but none of the cases are all upper case


#3

You asked for uppercase, so change you case to uppercase.

case 'BUSTER':
        console.log('Phelp\'s son?');
        break;

#4

Thank you very much for your clear explanations. :slight_smile:


#5

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