Add nullish coalescing to multiple articles, refactor operators, renumber the chapter
This commit is contained in:
parent
175aefa0b8
commit
8a13c992d6
54 changed files with 386 additions and 183 deletions
23
1-js/02-first-steps/14-switch/2-rewrite-if-switch/task.md
Normal file
23
1-js/02-first-steps/14-switch/2-rewrite-if-switch/task.md
Normal file
|
@ -0,0 +1,23 @@
|
|||
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' );
|
||||
}
|
||||
```
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue