Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 1-js/02-first-steps/13-switch/2-rewrite-if-switch/solution.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The first two checks turn into two `case`. The third check is split into two cases:
Primele două validări se transformă în două `case`-uri. A treia verificare este ruptă în două cazuri:

```js run
let a = +prompt('a?', '');
Expand All @@ -21,6 +21,6 @@ switch (a) {
}
```

Please note: the `break` at the bottom is not required. But we put it to make the code future-proof.
Te rog observă că: `break`-ul de la sfârșit nu este necesar. Dar îl punem pentru a face codul mai stabil în viitor.

In the future, there is a chance that we'd want to add one more `case`, for example `case 4`. And if we forget to add a break before it, at the end of `case 3`, there will be an error. So that's a kind of self-insurance.
În viitor se poate să vrem să adăugăm una sau mai multe ramuri `case`, spre exemplu `case 4`. Și dacă uităm să adăugăm un break înainte de el, la sfârșitul lui `case 3`, va exista o eroare. Așadar acest lucru este un fel de auto-asigurare.
9 changes: 4 additions & 5 deletions 1-js/02-first-steps/13-switch/2-rewrite-if-switch/task.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
importance: 4
importanță: 4

---

# Rewrite "if" into "switch"
# Rescrie "if" în "switch"

Rewrite the code below using a single `switch` statement:
Rescrie codul de mai jos folosind o singură afirmație `switch`:

```js run
let a = +prompt('a?', '');
Expand All @@ -19,5 +19,4 @@ if (a == 1) {
if (a == 2 || a == 3) {
alert( '2,3' );
}
```

```