diff --git a/1-js/2-first-steps/13-logical-ops/5-alert-and-or/solution.md b/1-js/2-first-steps/13-logical-ops/5-alert-and-or/solution.md index e02d8e49..03394072 100644 --- a/1-js/2-first-steps/13-logical-ops/5-alert-and-or/solution.md +++ b/1-js/2-first-steps/13-logical-ops/5-alert-and-or/solution.md @@ -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 +null || 3 || 4 ``` +Now the result if the first truthy value: `3`. + diff --git a/1-js/2-first-steps/13-logical-ops/5-alert-and-or/task.md b/1-js/2-first-steps/13-logical-ops/5-alert-and-or/task.md index 9e367c3b..af43c7bd 100644 --- a/1-js/2-first-steps/13-logical-ops/5-alert-and-or/task.md +++ b/1-js/2-first-steps/13-logical-ops/5-alert-and-or/task.md @@ -1,8 +1,8 @@ -# Что выведет этот код? +# The result of OR AND OR [importance 5] -Что выведет код ниже? +What will be the result? ```js alert( null || 2 && 3 || 4 ); diff --git a/1-js/2-first-steps/13-logical-ops/6-check-if-in-range/task.md b/1-js/2-first-steps/13-logical-ops/6-check-if-in-range/task.md index df16ad99..bfe791f9 100644 --- a/1-js/2-first-steps/13-logical-ops/6-check-if-in-range/task.md +++ b/1-js/2-first-steps/13-logical-ops/6-check-if-in-range/task.md @@ -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`. \ No newline at end of file +"Inclusively" means that `age` can reach the edges `14` or `90`. diff --git a/1-js/2-first-steps/13-logical-ops/7-check-if-out-range/solution.md b/1-js/2-first-steps/13-logical-ops/7-check-if-out-range/solution.md index 3d2eab1a..d1946a96 100644 --- a/1-js/2-first-steps/13-logical-ops/7-check-if-out-range/solution.md +++ b/1-js/2-first-steps/13-logical-ops/7-check-if-out-range/solution.md @@ -1,10 +1,10 @@ -Первый вариант: +The first variant: ```js if (!(age >= 14 && age <= 90)) ``` -Второй вариант: +The second variant: ```js if (age < 14 || age > 90) diff --git a/1-js/2-first-steps/13-logical-ops/7-check-if-out-range/task.md b/1-js/2-first-steps/13-logical-ops/7-check-if-out-range/task.md index 1d833664..bc982f87 100644 --- a/1-js/2-first-steps/13-logical-ops/7-check-if-out-range/task.md +++ b/1-js/2-first-steps/13-logical-ops/7-check-if-out-range/task.md @@ -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. -Сделайте два варианта условия: первый с использованием оператора НЕ `!`, второй - без этого оператора. \ No newline at end of file +Create two variants: the first one using NOT `!`, the second one -- without it. diff --git a/1-js/2-first-steps/13-logical-ops/8-if-question/solution.md b/1-js/2-first-steps/13-logical-ops/8-if-question/solution.md index f1b83dab..643e326f 100644 --- a/1-js/2-first-steps/13-logical-ops/8-if-question/solution.md +++ b/1-js/2-first-steps/13-logical-ops/8-if-question/solution.md @@ -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' ); ``` diff --git a/1-js/2-first-steps/13-logical-ops/8-if-question/task.md b/1-js/2-first-steps/13-logical-ops/8-if-question/task.md index ee7018b6..5cd7526b 100644 --- a/1-js/2-first-steps/13-logical-ops/8-if-question/task.md +++ b/1-js/2-first-steps/13-logical-ops/8-if-question/task.md @@ -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' ); ```