Workflow does not function


#1

The code below always results in the default value. Can anyone help me on that?

var user = prompt("What is your name?").toLowerCase();

console.log(user.length);

switch(user.length) {

case user.length<3:
  console.log("You have a very short name!");
  break;

  case user.length<8 && user.length>2:
  console.log("Your name has a normal length!");
  break;

  case user.length<12 && user.length>7:
  console.log("You have a long name!");
  break;

  default:
  console.log("Wow, your name is very long!");

}


#2

I don't know about JS in particular but in other languages, switches typically don't allow conditions, it's just matching against constants.

If you enter a one-letter word, then you might match the first case because the expression would evaluate to true which might match 1 which is the length of your word... maybe. Or perhaps that'd reach the default case as well.