Skip to content

Instantly share code, notes, and snippets.

@suhailgupta03
Created May 10, 2023 15:04
Show Gist options
  • Save suhailgupta03/ad5b33d60be3faf8a2411ddc418b7740 to your computer and use it in GitHub Desktop.
Save suhailgupta03/ad5b33d60be3faf8a2411ddc418b7740 to your computer and use it in GitHub Desktop.
var y = 200; // Assign 100 to y
switch(y){ // switch is taking 'y' as a value
// to validate
case 200: // will check if y == 200
console.log("this is 200");
break; // this will exit the switch block
case 300: // will check if y == 300
console.log("this is 300");
break;
default: // if none of the condition is true
// it will execute the default case
console.log("This is the default case");
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment