Skip to content

Instantly share code, notes, and snippets.

@hossainlab
Created April 20, 2019 07:56
Show Gist options
  • Select an option

  • Save hossainlab/b22bae573b44adcd1bd5c065fe996942 to your computer and use it in GitHub Desktop.

Select an option

Save hossainlab/b22bae573b44adcd1bd5c065fe996942 to your computer and use it in GitHub Desktop.
const color = 'red';
switch(color) {
case 'red':
console.log('Color is red!');
break;
case 'blue':
console.log('Color is blue!');
break;
default:
console.log('Color is not red or blue!');
break;
}
// A lot of different cases
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}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment