en.javascript.info/1-js/02-first-steps/14-switch/2-rewrite-if-switch/task.md

23 lines
257 B
Markdown

importance: 4
---
# Rewrite "if" into "switch"
Rewrite the code below using a single `switch` statement:
```js run
let a = +prompt('a?', '');
if (a == 0) {
alert( 0 );
}
if (a == 1) {
alert( 1 );
}
if (a == 2 || a == 3) {
alert( '2,3' );
}
```