en.javascript.info/1-js/02-first-steps/13-switch/2-rewrite-if-switch/task.md
Ilya Kantor 9ad9063d00 up
2016-11-28 21:35:42 +03:00

257 B

importance: 4


Rewrite "if" into "switch"

Rewrite the code below using a single switch statement:

let a = +prompt('a?', '');

if (a == 0) {
  alert( 0 );
}
if (a == 1) {
  alert( 1 );
}

if (a == 2 || a == 3) {
  alert( '2,3' );
}