Skip to content

Commit 0939f2a

Browse files
committed
Update conditional branching
1 parent fc8f288 commit 0939f2a

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22

33
```js
4-
result = (a + b < 4) ? 'Below' : 'Over';
4+
let result = (a + b < 4) ? 'Below' : 'Over';
55
```
66

1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ importance: 5
44

55
# Rewrite 'if' into '?'
66

7-
Rewrite this `if` using the ternary operator `'?'`:
7+
Rewrite this `if` using the conditional operator `'?'`:
88

99
```js
10+
let result;
11+
1012
if (a + b < 4) {
1113
result = 'Below';
1214
} else {
1315
result = 'Over';
1416
}
1517
```
16-

1-js/02-first-steps/10-ifelse/article.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ if (cond) {
6868

6969
## The "else" clause
7070

71-
The `if` statement may contain an optional "else" block. It executes when the condition is falsy.
71+
The `if` statement may contain an optional `else` block. It executes when the condition is falsy.
7272

7373
For example:
7474
```js run
@@ -181,9 +181,9 @@ alert( message );
181181
It may be difficult at first to grasp what's going on. But after a closer look, we can see that it's just an ordinary sequence of tests:
182182

183183
1. The first question mark checks whether `age < 3`.
184-
2. If true -- it returns `'Hi, baby!'`. Otherwise, it continues to the expression after the colon '":"', checking `age < 18`.
185-
3. If that's true -- it returns `'Hello!'`. Otherwise, it continues to the expression after the next colon '":"', checking `age < 100`.
186-
4. If that's true -- it returns `'Greetings!'`. Otherwise, it continues to the expression after the last colon '":"', returning `'What an unusual age!'`.
184+
2. If true -- it returns `'Hi, baby!'`. Otherwise, it continues to the expression after the colon ":", checking `age < 18`.
185+
3. If that's true -- it returns `'Hello!'`. Otherwise, it continues to the expression after the next colon ":", checking `age < 100`.
186+
4. If that's true -- it returns `'Greetings!'`. Otherwise, it continues to the expression after the last colon ":", returning `'What an unusual age!'`.
187187

188188
Here's how this looks using `if..else`:
189189

0 commit comments

Comments
 (0)