details of switch case statement

      A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case.

Syntax

switch(expression)

{

  case condition_variable-1:

          statements;

          break;

  case condition_variable-2:

          statements;

          break;

  case condition_variable-3:

          statements;

          break;

      --------------

      --------------

      --------------

  case condition_variable-n:

          statements;

          break;



default:

           statements;

}


Example

a=3;

switch(a)

case 1:

{

      alert("One");

      break;

case 2:

      alert("Two");

      break;

case 3:

      alert("Three");

      break;

default:

       alert("no condition matched");

}



Flow Chart


Example Program:- (Editor)


Editor is Loading...

Advertisement





Tags:
switch case statement in allinworld99, switch in javascript, case statement in javascript,switch and case in allinworld99 javascript.

0 nhận xét:

Đăng nhận xét