I am trying to convert this python code to switch: Python code I am trying to convert
However, I tried converting it and the only method I have found is using this:
var age = prompt("What is your age?");
age = parseInt(age);
switch(age) {
case 1: case 2: case 3:
console.log("You are under 4")
break;
default:
console.log("I do not recognize your number")
}
I am aware that is not the full code from Python to switch case, but is there an easier way to do it than inputting every number individually by doing case:'number':
rather than how you would normally sort of do it in python like this: (1<= number <= 3)
Any help would be much appreciated