translation

This commit is contained in:
Ilya Kantor 2015-08-27 23:23:23 +03:00
parent cd86e9993b
commit ab936483cd
7 changed files with 36 additions and 35 deletions

View file

@ -1,16 +1,17 @@
Ответ: `3`.
The answer: `3`.
```js
//+ run
alert( null || 2 && 3 || 4 );
```
Приоритет оператора `&&` выше, чем `||`, поэтому он выполнится первым.
The precedence of AND `&&` is higher than `||`, so it executes first.
The result of `2 && 3 = 3`, so the expression becomes:
Последовательность вычислений:
```
null || 2 && 3 || 4
null || 3 || 4
3
```
Now the result if the first truthy value: `3`.

View file

@ -1,8 +1,8 @@
# Что выведет этот код?
# The result of OR AND OR
[importance 5]
Что выведет код ниже?
What will be the result?
```js
alert( null || 2 && 3 || 4 );

View file

@ -1,7 +1,7 @@
# Проверка if внутри диапазона
# Check the range between
[importance 3]
Напишите условие `if` для проверки того факта, что переменная `age` находится между `14` и `90` включительно.
Write an "if" condition to check that `age` is between `14` and `90` inclusively.
"Включительно" означает, что концы промежутка включены, то есть `age` может быть равна `14` или `90`.
"Inclusively" means that `age` can reach the edges `14` or `90`.

View file

@ -1,10 +1,10 @@
Первый вариант:
The first variant:
```js
if (!(age >= 14 && age <= 90))
```
Второй вариант:
The second variant:
```js
if (age < 14 || age > 90)

View file

@ -1,7 +1,7 @@
# Проверка if вне диапазона
# Check the range outside
[importance 3]
Напишите условие `if` для проверки того факта, что `age` НЕ находится между 14 и 90 включительно.
Write an `if` condition to check that `age` is NOT between 14 and 90 inclusively.
Сделайте два варианта условия: первый с использованием оператора НЕ `!`, второй - без этого оператора.
Create two variants: the first one using NOT `!`, the second one -- without it.

View file

@ -1,21 +1,21 @@
Ответ: первое и третье выполнятся.
The answer: the first and the third will execute.
Детали:
Details:
```js
//+ run
// Выполнится
// Результат -1 || 0 = -1, в логическом контексте true
if (-1 || 0) alert( 'первое' );
// Runs.
// The result of -1 || 0 = -1, truthy
if (-1 || 0) alert( 'first' );
// Не выполнится
// -1 && 0 = 0, в логическом контексте false
if (-1 && 0) alert( 'второе' );
// Doesn't run
// -1 && 0 = 0, falsy
if (-1 && 0) alert( 'second' );
// Выполнится
// оператор && имеет больший приоритет, чем ||
// так что -1 && 1 выполнится раньше
// вычисления: null || -1 && 1 -> null || 1 -> 1
if (null || -1 && 1) alert( 'третье' );
// Executes
// Operator && has a higher precedence than ||
// so -1 && 1 executes first, giving us the chain:
// null || -1 && 1 -> null || 1 -> 1
if (null || -1 && 1) alert( 'third' );
```

View file

@ -1,14 +1,14 @@
# Вопрос про "if"
# A question about "if"
[importance 5]
Какие из этих `if` верны, т.е. выполнятся?
Which of these `alert`s are going to execute?
Какие конкретно значения будут результатами выражений в условиях `if(...)`?
What will be the results of the expressions inside `if(...)`?
```js
if (-1 || 0) alert( 'первое' );
if (-1 && 0) alert( 'второе' );
if (null || -1 && 1) alert( 'третье' );
if (-1 || 0) alert( 'first' );
if (-1 && 0) alert( 'second' );
if (null || -1 && 1) alert( 'third' );
```