Skip to content

Commit 70dfe97

Browse files
authored
Update article.md
1 parent 9b39291 commit 70dfe97

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Conditional operators: if, '?'
22

3-
Sometimes we need to perform different actions basing on a condition.
3+
Sometimes we need to perform different actions based on a condition.
44

5-
There's an `if` operator for that and also the "question mark" operator: `"?"` for conditional evaluation.
5+
There is `if` statement for that and also the conditional (ternary) operator for conditional evaluation which we will be referring as “question mark operator: "?" for simplicity.
66

77
[cut]
88

9-
## The "if" operator
9+
## The "if" statement
1010

11-
The "if" operator gets a condition, evaluates it and -- if the result is `true` -- executes the code.
11+
The "if" statement gets a condition, evaluates it and -- if the result is `true` -- executes the code.
1212

1313
For example:
1414

@@ -22,7 +22,7 @@ if (year == 2015) alert( 'You are right!' );
2222

2323
In the example above, the condition is a simple equality check: `year == 2015`, but it can be much more complex.
2424

25-
If there's more than one command to execute -- we can use a code block in figure brackets:
25+
If there is more than one command to execute -- we can use a code block in figure brackets:
2626

2727
```js
2828
if (year == 2015) {
@@ -31,11 +31,11 @@ if (year == 2015) {
3131
}
3232
```
3333

34-
It is recommended to use figure brackets every time with `if`, even if there's only one command. That improves readability.
34+
It is recommended to use figure brackets every time with `if`, even if there is only one command. That improves readability.
3535

3636
## Boolean conversion
3737

38-
The `if (…)` operator evaluates the expression in parentheses and converts it to the boolean type.
38+
The `if (…)` statement evaluates the expression in parentheses and converts it to the boolean type.
3939

4040
Let's recall the conversion rules from the chapter <info:type-conversions>:
4141

@@ -70,7 +70,7 @@ if (cond) {
7070

7171
## The "else" clause
7272

73-
The `if` operator may contain an optional "else" block. It executes when the condition is wrong.
73+
The `if` statement may contain an optional "else" block. It executes when the condition is wrong.
7474

7575
For example:
7676
```js run
@@ -85,7 +85,7 @@ if (year == 2015) {
8585

8686
## Several conditions: "else if"
8787

88-
Sometimes we'd like to test several variants of a condition. There's an `else if` clause for that.
88+
Sometimes we'd like to test several variants of a condition. There is an `else if` clause for that.
8989

9090
For example:
9191

@@ -220,7 +220,7 @@ We don't assign a result to a variable here, the idea is to execute different co
220220

221221
The notation seem to be shorter than `if`, that appeals to some programmers. But it is less readable.
222222

223-
Here's the same with `if` for comparison:
223+
Here is the same with `if` for comparison:
224224

225225
```js run no-beautify
226226
let company = prompt('Which company created JavaScript?', '');
@@ -236,4 +236,4 @@ if (company == 'Netscape') {
236236

237237
Our eyes scan the code vertically. The constructs which span several lines are easier to understand than a long horizontal instruction set.
238238

239-
The idea of a question mark `'?'` is to return one or another value depending on the condition. Please use it for exactly that. There's `if` to execute different branches of the code.
239+
The idea of a question mark `'?'` is to return one or another value depending on the condition. Please use it for exactly that. There is `if` to execute different branches of the code.

0 commit comments

Comments
 (0)