javascript integer switch code example

Example 1: switch case in js

var coll1="kjc;

switch(coll1)
{
  case "kjc":
    alert("youre special");
    break;
  case "horizon":
    alert("worst behaviour");
    break;
  case "cmr" :
    alert("worst character");
    break;
  default:
    alert("kjc is best");
    break;
}

Example 2: how to use switch case in javascript

switch (expression) {
  case value1:
    //Statements executed when the
    //result of expression matches value1
    [break;]
  case value2:
    //Statements executed when the
    //result of expression matches value2
    [break;]
  ...
  case valueN:
    //Statements executed when the
    //result of expression matches valueN
    [break;]
  [default:
    //Statements executed when none of
    //the values match the value of the expression
    [break;]]
}