Check out example codes for "swich case arduino". It will help you in understanding the concepts better.

Code Example 1

// Arduino => c++
switch (var) {
  case 1:
    //do something when var equals 1
    break;
  case 2:
    //do something when var equals 2
    break;
  default:
    // if nothing else matches, do the default
    // default is optional
    break;
}

Learn ReactJs, React Native from akashmittal.com