Skip to content

Commit 81b1fd9

Browse files
committed
saveing progress
1 parent ddffb12 commit 81b1fd9

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

  • 1-js/02-first-steps/11-logical-operators

1-js/02-first-steps/11-logical-operators/article.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ result = a || b;
1616

1717
У класичному програмуванні логічний OR призначений для маніпулювання лише булевими значеннями. Якщо будь-який з його аргументів `true`, він повертає `true`, інакше повертає `false`.
1818

19-
In JavaScript, the operator is a little bit trickier and more powerful. But first, let's see what happens with boolean values.
19+
У JavaScript оператор більш складніший і потужніший. Але спочатку подивимося, що відбувається з булевими значеннями.
2020

21-
There are four possible logical combinations:
21+
Є чотири можливі логічні комбінації:
2222

2323
```js run
2424
alert( true || true ); // true
@@ -27,40 +27,40 @@ alert( true || false ); // true
2727
alert( false || false ); // false
2828
```
2929

30-
As we can see, the result is always `true` except for the case when both operands are `false`.
30+
Як бачимо, результат завжди `true`, за винятком випадку, коли обидва операнда `false`.
3131

32-
If an operand is not a boolean, it's converted to a boolean for the evaluation.
32+
Якщо операнд не є булевим, він перетворюється на логічний для обчислення.
3333

34-
For instance, the number `1` is treated as `true`, the number `0` as `false`:
34+
Наприклад, число `1` розглядається як `true`, число `0` — як `false`:
3535

3636
```js run
37-
if (1 || 0) { // works just like if( true || false )
38-
alert( 'truthy!' );
37+
if (1 || 0) { // працює так само, як ( true || false )
38+
alert( 'правдиво!' );
3939
}
4040
```
4141

42-
Most of the time, OR `||` is used in an `if` statement to test if *any* of the given conditions is `true`.
42+
У бильшості випадків OR `||` використовується в операторі `if`, щоб перевірити, чи є *будь-яка* з заданих умов `true`.
4343

44-
For example:
44+
Наприклад:
4545

4646
```js run
4747
let hour = 9;
4848

4949
*!*
5050
if (hour < 10 || hour > 18) {
5151
*/!*
52-
alert( 'The office is closed.' );
52+
alert( 'Офіс зачинений.' );
5353
}
5454
```
5555

56-
We can pass more conditions:
56+
Ми можемо передавати більше умов:
5757

5858
```js run
5959
let hour = 12;
6060
let isWeekend = true;
6161

6262
if (hour < 10 || hour > 18 || isWeekend) {
63-
alert( 'The office is closed.' ); // it is the weekend
63+
alert( 'Офіс зачинений.' ); // цу вихідні
6464
}
6565
```
6666

0 commit comments

Comments
 (0)