var number = 15;
switch(number) {
default:
console.log(‘No match found’);
break;
case 5:
console.log(‘number is 5’);
break;
case 10:
console.log(‘number is 10’);
break;
case 15:
console.log(‘number is 15’);
}
Sometimes when writing a switch statement, you will come across a situation where you might want multiple cases to perform the same action. Switch statements make this very easy. You can simply chain together multiple case statements before your code, then that code will be assigned to both cases. Let’s see what we mean by this with an example.