Only returning the last line


#1

I've pasted my code below. Only the default line is returning, regardless of the number input in response to the prompt. Can anyone shed light as to why that is?

var number = prompt("What's your favourite number, between 0 and 100?", "Insert number here");

switch(number) {
case (number<25):
console.log("Going for the lower quarter of the possibilities!");
break;
case (25 <= number < 50):
console.log("Second quarter!");
break;
case (50 <= number < 75):
console.log("Third quarter!");
break;
case (75 <= number <=100):
console.log("The top quarter!");
break;
default:
console.log("That's not between 0 and 100!");
};


#2

A switch works this way. you pick the first case that matches the value after switch. So if you want to use conditions you need to use switch(true). In this case the first condition that is true is chosen. Also these don't work:

25 <= number < 50

either google for && (boolean AND operator) or || (boolean OR operator) or think if you really need both boundaries for a range.