You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/10-ifelse/article.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,20 @@
1
-
# Conditional branching: if, '?'
1
+
# Шарттуу бутактануу: if, '?'
2
2
3
3
Sometimes, we need to perform different actions based on different conditions.
4
4
5
5
To do that, we can use the `if` statement and the conditional operator `?`, that's also called a "question mark" operator.
6
6
7
-
## The "if" statement
7
+
## "if" нускамасы
8
8
9
9
The `if(...)` statement evaluates a condition in parentheses and, if the result is `true`, executes a block of code.
10
10
11
-
For example:
11
+
Мисалы:
12
12
13
13
```js run
14
14
let year =prompt('In which year was ECMAScript-2015 specification published?', '');
15
15
16
16
*!*
17
-
if (year ==2015) alert( 'You are right!' );
17
+
if (year ==2015) alert( 'Туура айтасыз!' );
18
18
*/!*
19
19
```
20
20
@@ -24,14 +24,14 @@ If we want to execute more than one statement, we have to wrap our code block in
24
24
25
25
```js
26
26
if (year ==2015) {
27
-
alert( "That's correct!" );
28
-
alert( "You're so smart!" );
27
+
alert( "Бул туура!" );
28
+
alert( "Сиз абдан акылдуусуз!" );
29
29
}
30
30
```
31
31
32
32
We recommend wrapping your code block with curly braces `{}` every time you use an `if` statement, even if there is only one statement to execute. Doing so improves readability.
33
33
34
-
## Boolean conversion
34
+
## Логикалык айландыруу
35
35
36
36
The `if (…)` statement evaluates the expression in its parentheses and converts the result to a boolean.
37
37
@@ -43,15 +43,15 @@ Let's recall the conversion rules from the chapter <info:type-conversions>:
43
43
So, the code under this condition would never execute:
0 commit comments