Skip to content

Instantly share code, notes, and snippets.

@suhailgupta03
Created May 10, 2023 15:56
Show Gist options
  • Save suhailgupta03/eb568c578b28c52ad27a3bd9ddf96322 to your computer and use it in GitHub Desktop.
Save suhailgupta03/eb568c578b28c52ad27a3bd9ddf96322 to your computer and use it in GitHub Desktop.
var y = -2; // assign -2 to y
var z = true;
switch(z) { // initialze the switch statement
// with a number
case y < 0: // y < 0 ---> true --> -2 != true
console.log("less than 0");
break;
case 100:
console.log(100);
break;
case 200:
console.log(200);
break;
default:
console.log("The default case");
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment