Continued on


#1

Continuing the discussion from 4/6 Switch. Only default happening:

So I have to put something like this ?



var user = prompt("What is your name player").toUpperCase();
switch(user) {
    case (3 || 4)
    console.log("You have a short name")
    break;


And so on throughout the code, right?


#2

Hi you should first close the switch statement

switch (condition) {
  
//here your code

};

then you case it's mising the : after case (3 || 4)


#3

What do you mean by "closing the switch statement"?


#4

I mean

switch (condition) {//open the switch statement
  
//here your code

};//close the switch statement

#5

Oh okay, In my actual code I do have that though


#6

Do you still have an error ? if so can you post your new code?


#7

var user = prompt("What is your name, player").toLowerCase();
switch(user) {
case user === (3 || 4):
console.log("You have a short name " + user);
break;

case user === (6 || 5):
    console.log("That name is about average length " + user);
    break;

case user === (7 || 8 || 9 || 10 || 11):
    console.log("Wow, you have a long name!");
    break;

case user === (0):
    console.log("That's not even a name, you didn't type anything");
    break;

default:
    console.log("Is that even a name?");

};


#8

It just comes up with the default message "Is that even a name?"


#9

Don't worry I figured it out


#10

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