const color='green';
switch(color){
case 'red':
console.log('color is red');
break;
case 'blue':
console.log('color is blue');
break;
case 'yellow':
console.log('color is yellow');
break;
default:
console.log('color is not at all');
break;//用于跳出当前的case
}
let day;
switch(new Date().getDay()){
case 0:
day='sunday';
break;
case 1:
day='monday';
break;
case 2:
day='tuesday';
break;
case 3:
day='wednesday';
break;
case 4:
day='thursday';
break;
case 5:
day='friday';
break;
case 6:
day='saturday';
break;
}
console.log(`today is ${day}`)
