Switch - Javascript

A quick lesson on switch conditionals

Switch statement can also be used to execute block of codes based on certain condition.

Example:

const rank = "Captain";
switch(rank){
  case "Engineer":
    console.log("Engineer Here!");
    break;
  case "Major":
    console.log("Aye Aye Major");
    break;
  case "Captain":
    console.log("Hey Captain");
    break;
  default:
    console.log("Unknown Rank");
}

Output:

Hey Captain