chore(i18n,learn): processed translations (#48105)

This commit is contained in:
camperbot
2022-10-18 08:29:49 +01:00
committed by GitHub
parent e22f87a085
commit 41bbc30b94
6193 changed files with 34024 additions and 29301 deletions

View File

@@ -19,21 +19,19 @@ dashedName: access-array-data-with-indexes
```js
const array = [50, 60, 70];
array[0];
console.log(array[0]);
const data = array[1];
```
`array[0]` становить `50`, і`data` має значення `60`.
**Примітка:** ніколи не вставляйте пробіл між ім'ям масиву і квадратними дужками, наприклад `array [0]`. Хоча JavaScript прочитає це правильно, але це може створити труднощі для інших програмістів, які читатимуть ваш код.
The `console.log(array[0])` prints `50`, and `data` has the value `60`.
# --instructions--
Створіть змінну з назвою `myData` і встановіть її значення рівне до першому елементу `myArray`, використовуючи квадратні дужки.
Create a variable called `myData` and set it to equal the first value of `myArray` using bracket notation.
# --hints--
Змінна `myData` повинна дорівнювати першому значенню `myArray`.
The variable `myData` should equal the first value of `myArray`.
```js
assert(
@@ -51,7 +49,7 @@ assert(
);
```
До даних в змінній `myArray` слід отримати доступ за допомогою індексу у квадратних дужках.
The data in variable `myArray` should be accessed using bracket notation.
```js
assert(

View File

@@ -21,12 +21,12 @@ const arr = [
[[10, 11, 12], 13, 14]
];
arr[3];
arr[3][0];
arr[3][0][1];
const subarray = arr[3];
const nestedSubarray = arr[3][0];
const element = arr[3][0][1];
```
`arr[3]` є `[[10, 11, 12], 13, 14]`, `arr[3][0]` є `[10, 11, 12]`, і `arr[3][0][1]` є `11`.
In this example, `subarray` has the value `[[10, 11, 12], 13, 14]`, `nestedSubarray` has the value `[10, 11, 12]`, and `element` has the value `11` .
**Примітка:** ніколи не вставляйте пробіл між ім'ям масиву і квадратними дужками, наприклад, так `array [0][0]` і навіть так `array [0] [0]` не можна робити. Незважаючи на те, що для JavaScript це є дрібницею, ця звичка може ускладнити читання коду іншими програмістами.

View File

@@ -27,63 +27,45 @@ console.log(myBreed);
У консолі відображатиметься рядок `Doberman`.
Інший спосіб, у який можна використовувати цей метод, - коли назви властивостей активно накопичуються протягом роботи у програмі, як показано далі:
```js
const someObj = {
propName: "John"
};
function propPrefix(str) {
const s = "prop";
return s + str;
}
const someProp = propPrefix("Name");
console.log(someObj[someProp]);
```
`someProp` матиме значення рядка `propName`, і рядок `John` відображатиметься в консолі.
Зверніть увагу, що ми *не* використовуємо лапки із змінними назвами, коли нам потрібен доступ до властивостей, тому що ми використовуємо *значення* змінної, а не її *назву*.
Note that we do *not* use quotes around the variable name when using it to access the property because we are using the *value* of the variable, not the *name*.
# --instructions--
Вкажіть, що `playerNumber` може змінюватися до `16`. Потім використовуйте змінну для пошуку імені гравця та закріпіть її за `player`.
Set the `playerNumber` variable to `16`. Then, use the variable to look up the player's name and assign it to `player`.
# --hints--
`playerNumber` має бути числом
`playerNumber` should be a number
```js
assert(typeof playerNumber === 'number');
```
Змінна `player` повинна бути рядком
The variable `player` should be a string
```js
assert(typeof player === 'string');
```
Значення `player` повинне бути рядком `Montana`
The value of `player` should be the string `Montana`
```js
assert(player === 'Montana');
```
Використовуйте дужкову нотацію, щоб отримати доступ до `testObj`
You should use bracket notation to access `testObj`
```js
assert(/testObj\s*?\[.*?\]/.test(code));
```
Значення `Montana` не можна закріплювати безпосередньо за змінною `player`.
You should not assign the value `Montana` to the variable `player` directly.
```js
assert(!code.match(/player\s*=\s*"|\'\s*Montana\s*"|\'\s*;/gi));
```
Слід використовувати змінну `playerNumber` у квадратних дужках
You should be using the variable `playerNumber` in your bracket notation
```js
assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(code));

View File

@@ -9,7 +9,7 @@ dashedName: assignment-with-a-returned-value
# --description--
Якщо Ви пригадаєте з нашого обговорення [Storing Values with the Assignment Operator](/learn/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator), все, що знаходиться справа від знака рівності визначається ще до того, як присвоюється значення. Це означає, що ми можемо взяти повернене значення функції та присвоїти її змінній.
If you'll recall from our discussion about <a href="/learn/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank" rel="noopener noreferrer nofollow">Storing Values with the Assignment Operator</a>, everything to the right of the equal sign is resolved before the value is assigned. Це означає, що ми можемо взяти повернене значення функції та присвоїти її змінній.
Припустимо, у нас уже є визначена функція `sum`, яка додає два числа, тоді:

View File

@@ -27,7 +27,7 @@ dashedName: comment-your-javascript-code
multi-line comment */
```
**ПРИМІТКА:**, написавши код, вам слід постійно додавати коментарі, щоб уточнити функцію частин вашого коду. Хороші і якісні коментарі допоможуть допомогти розібратись в значенні вашого коду - як для іншим людям, так і *and* для вас у майбутньому.
**ПРИМІТКА:**, написавши код, вам слід постійно додавати коментарі, щоб уточнити функцію частин вашого коду. Хороші і якісні коментарі можуть допомогти передати мету вашого коду як для інших людей, *так і* для себе в майбутньому.
# --instructions--

View File

@@ -25,39 +25,37 @@ function equalityTest(myVal) {
Якщо `myVal` рівнозначний `10`, оператор рівності видає `true`, тож код у фігурних дужках виконається, і функція буде `Equal`. В іншому випадку, функція буде `Not Equal`. Для того, щоб JavaScript порівняв два різні <dfn>типи даних</dfn> (наприклад, `numbers` і `strings`), потрібно конвертувати один тип в інший. Це називається Перетворення Типів. Однак, після його виконання поняття порівнюються наступним чином:
```js
1 == 1
1 == 2
1 == '1'
"3" == 3
1 == 1 // true
1 == 2 // false
1 == '1' // true
"3" == 3 // true
```
У такому ж порядку, як вони є, ці вирази будуть оцінені, як `true`, `false`, `true`, і `true`.
# --instructions--
Додайте оператор рівності до зазначеного рядка, щоб функція визначила рядок, як `Equal`, коли `val` еквівалентна `12`.
Add the equality operator to the indicated line so that the function will return the string `Equal` when `val` is equivalent to `12`.
# --hints--
`testEqual(10)` повинен повернути рядок `Not Equal`
`testEqual(10)` should return the string `Not Equal`
```js
assert(testEqual(10) === 'Not Equal');
```
`testEqual(12)` повинен повернути рядок `Equal`
`testEqual(12)` should return the string `Equal`
```js
assert(testEqual(12) === 'Equal');
```
`testEqual("12")` повинен повернути рядок `Equal`
`testEqual("12")` should return the string `Equal`
```js
assert(testEqual('12') === 'Equal');
```
Слід використовувати оператор `==`
You should use the `==` operator
```js
assert(code.match(/==/g) && !code.match(/===/g));

View File

@@ -16,21 +16,19 @@ dashedName: comparison-with-the-greater-than-operator
**Приклади**
```js
5 > 3
7 > '3'
2 > 3
'1' > 9
5 > 3 // true
7 > '3' // true
2 > 3 // false
'1' > 9 // false
```
По-порядку, ці вирази оцінюватимуться як `true`, `true`, `false`, та `false`.
# --instructions--
Додайте оператор «більше ніж» до вказаних рядків, щоб оператор повернення спрацював.
Add the greater than operator to the indicated lines so that the return statements make sense.
# --hints--
`GreaterThan(0)` має повернути рядок `10 або Under`
`testGreaterThan(0)` має повернути рядок `10 or Under`
```js
assert(testGreaterThan(0) === '10 or Under');
@@ -72,7 +70,7 @@ assert(testGreaterThan(101) === 'Over 100');
assert(testGreaterThan(150) === 'Over 100');
```
Ви повинні використати оператор `>` принаймні двічі
You should use the `>` operator at least twice
```js
assert(code.match(/val\s*>\s*('|")*\d+('|")*/g).length > 1);

View File

@@ -16,63 +16,61 @@ dashedName: comparison-with-the-greater-than-or-equal-to-operator
**Наприклад**
```js
6 >= 6
7 >= '3'
2 >= 3
'7' >= 9
6 >= 6 // true
7 >= '3' // true
2 >= 3 // false
'7' >= 9 // false
```
У такому ж порядку, як вони є, ці вирази будуть оцінені, як `true`, `true`, `false`, і `false`.
# --instructions--
Додайте оператор "більше ніж дорівнює" до зазначених рядків, щоб оператор повернення мав сенс.
Add the greater than or equal to operator to the indicated lines so that the return statements make sense.
# --hints--
`testGreaterOrEqual(0)` повинен повернути рядок `Less than 10`
`testGreaterOrEqual(0)` має повертати рядок `Less than 10`
```js
assert(testGreaterOrEqual(0) === 'Less than 10');
```
`testGreaterOrEqual(9)` повинен повернути рядок `Less than 10`
`testGreaterOrEqual(9)` має повертати рядок `Less than 10`
```js
assert(testGreaterOrEqual(9) === 'Less than 10');
```
`testGreaterOrEqual(10)` повинен повернути рядок `10 or Over`
`testGreaterOrEqual(10)` має повертати рядок `10 or Over`
```js
assert(testGreaterOrEqual(10) === '10 or Over');
```
`testGreaterOrEqual(11)` повинен повернути рядок `10 or Over`
`testGreaterOrEqual(11)` має повертати рядок `10 or Over`
```js
assert(testGreaterOrEqual(11) === '10 or Over');
```
`testGreaterOrEqual(19)` повинен повернути рядок `10 or Over`
`testGreaterOrEqual(19)` має повертати рядок `10 or Over`
```js
assert(testGreaterOrEqual(19) === '10 or Over');
```
`testGreaterOrEqual(100)` повинен повернути рядок `20 or Over`
`testGreaterOrEqual(100)` має повертати рядок `20 or Over`
```js
assert(testGreaterOrEqual(100) === '20 or Over');
```
`testGreaterOrEqual(21)` повинен повернути рядок `20 or Over`
`testGreaterOrEqual(21)` має повертати рядок `20 or Over`
```js
assert(testGreaterOrEqual(21) === '20 or Over');
```
Слід використовувати оператор `>=` принаймні двічі
You should use the `>=` operator at least twice
```js
assert(code.match(/val\s*>=\s*('|")*\d+('|")*/g).length > 1);

View File

@@ -14,18 +14,16 @@ dashedName: comparison-with-the-inequality-operator
**Наприклад**
```js
1 != 2
1 != "1"
1 != '1'
1 != true
0 != false
1 != 2 // true
1 != "1" // false
1 != '1' // false
1 != true // false
0 != false // false
```
У такому ж порядку, як вони є, ці вирази будуть оцінені, як `true`, `false`, `false`, `false` і `false`.
# --instructions--
Додайте оператора нерівності `!=` до команди `if`, щоб функція повернула рядок `Not Equal`, коли `val` не дорівнює `99`.
Add the inequality operator `!=` in the `if` statement so that the function will return the string `Not Equal` when `val` is not equivalent to `99`.
# --hints--
@@ -59,7 +57,7 @@ assert(testNotEqual('12') === 'Not Equal');
assert(testNotEqual('bob') === 'Not Equal');
```
Слід використовувати оператор `!=`
You should use the `!=` operator
```js
assert(code.match(/(?!!==)!=/));

View File

@@ -14,58 +14,56 @@ dashedName: comparison-with-the-less-than-operator
**Наприклад:**
```js
2 < 5
'3' < 7
5 < 5
3 < 2
'8' < 4
2 < 5 // true
'3' < 7 // true
5 < 5 // false
3 < 2 // false
'8' < 4 // false
```
Відповідно, ці вирази будуть оцінені як `true`, `true`, `false`, `false`, та `false`.
# --instructions--
Додайте оператор "менше ніж" до вказаних рядків, щоб оператор повернення спрацював.
Add the less than operator to the indicated lines so that the return statements make sense.
# --hints--
`testLessThan(0)` повинен видати рядок `Under 25`
`testLessThan(0)` повинен повертати рядок `Under 25`
```js
assert(testLessThan(0) === 'Under 25');
```
`testLessThan(24)` повинен видати рядок `Under 25`
`testLessThan(24)` повинен повертати рядок `Under 25`
```js
assert(testLessThan(24) === 'Under 25');
```
`testLessThan(25)` повинен видати рядок `Under 55`
`testLessThan(25)` повинен повертати рядок `Under 55`
```js
assert(testLessThan(25) === 'Under 55');
```
`testLessThan(54)` повинен видати рядок `Under 55`
`testLessThan(54)` повинен повертати рядок `Under 55`
```js
assert(testLessThan(54) === 'Under 55');
```
`testLessThan(55)` повинен видати рядок `55 or Over`
`testLessThan(55)` повинен повертати рядок `55 or Over`
```js
assert(testLessThan(55) === '55 or Over');
```
`testLessThan(99)` повинен видати рядок `55 or Over`
`testLessThan(99)` повинен повертати рядок `55 or Over`
```js
assert(testLessThan(99) === '55 or Over');
```
Оператор `<` потрібно використати принаймні двічі
You should use the `<` operator at least twice
```js
assert(code.match(/val\s*<\s*('|")*\d+('|")*/g).length > 1);

View File

@@ -14,64 +14,62 @@ dashedName: comparison-with-the-less-than-or-equal-to-operator
**Наприклад:**
```js
4 <= 5
'7' <= 7
5 <= 5
3 <= 2
'8' <= 4
4 <= 5 // true
'7' <= 7 // true
5 <= 5 // true
3 <= 2 // false
'8' <= 4 // false
```
Відповідно, ці вирази будуть оцінені як `true`, `true`, `true`, `false`, та `false`.
# --instructions--
Додайте оператор "менше або рівне до вказаних рядків, щоб оператор повернення спрацював.
Add the less than or equal to operator to the indicated lines so that the return statements make sense.
# --hints--
`testLessOrEqual(0)` повинен повернути рядок `Smaller Than or Equal to 12`
`testLessOrEqual(0)` should return the string `Smaller Than or Equal to 12`
```js
assert(testLessOrEqual(0) === 'Smaller Than or Equal to 12');
```
`testLessOrEqual(11)` повинен повернути рядок `Smaller Than or Equal to 12`
`testLessOrEqual(11)` should return the string `Smaller Than or Equal to 12`
```js
assert(testLessOrEqual(11) === 'Smaller Than or Equal to 12');
```
`testLessOrEqual(12)` повинен повернути рядок `Smaller Than or Equal to 12`
`testLessOrEqual(12)` should return the string `Smaller Than or Equal to 12`
```js
assert(testLessOrEqual(12) === 'Smaller Than or Equal to 12');
```
`testLessOrEqual(23)` повинен повернути рядок `Smaller Than or Equal to 24`
`testLessOrEqual(23)` should return the string `Smaller Than or Equal to 24`
```js
assert(testLessOrEqual(23) === 'Smaller Than or Equal to 24');
```
`testLessOrEqual(24)` повинен повернути рядок `Smaller Than or Equal to 24`
`testLessOrEqual(24)` should return the string `Smaller Than or Equal to 24`
```js
assert(testLessOrEqual(24) === 'Smaller Than or Equal to 24');
```
`testLessOrEqual(25)` повинен повернути рядок `More Than 24`
`testLessOrEqual(25)` should return the string `More Than 24`
```js
assert(testLessOrEqual(25) === 'More Than 24');
```
`testLessOrEqual(55)` повинен повернути рядок `More Than 24`
`testLessOrEqual(55)` should return the string `More Than 24`
```js
assert(testLessOrEqual(55) === 'More Than 24');
```
Оператор `<=` потрібно використати принаймні двічі
You should use the `<=` operator at least twice
```js
assert(code.match(/val\s*<=\s*('|")*\d+('|")*/g).length > 1);

View File

@@ -16,39 +16,37 @@ dashedName: comparison-with-the-strict-equality-operator
**Наприклад**
```js
3 === 3
3 === '3'
3 === 3 // true
3 === '3' // false
```
Ці умови повертаються відповідно `true` та `false` відповідно.
У другому прикладі, `3` є типом `Number`, а `'3'` є типом `String`.
In the second example, `3` is a `Number` type and `'3'` is a `String` type.
# --instructions--
Використовуйте оператора абсолютної рівності з командою `if`, щоб функція повернула рядок `Equal`, коли `val` точно дорівнює `7`.
Use the strict equality operator in the `if` statement so the function will return the string `Equal` when `val` is strictly equal to `7`.
# --hints--
`testStrict(10)` перетворюється в рядку на `Not Equal`
`testStrict(10)` should return the string `Not Equal`
```js
assert(testStrict(10) === 'Not Equal');
```
`testStrict(7)` перетворюється в рядку на `Equal`
`testStrict(7)` should return the string `Equal`
```js
assert(testStrict(7) === 'Equal');
```
`testStrict("7")` перетворюється в рядку на `Not Equal`
`testStrict("7")` should return the string `Not Equal`
```js
assert(testStrict('7') === 'Not Equal');
```
Вам слід використовувати оператора `===`
You should use the `===` operator
```js
assert(code.match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0);

View File

@@ -14,44 +14,42 @@ dashedName: comparison-with-the-strict-inequality-operator
**Приклади**
```js
3 !== 3
3 !== '3'
4 !== 3
3 !== 3 // false
3 !== '3' // true
4 !== 3 // true
```
У такому порядку, ці вирази будуть оцінювати, як `false`, `true`,`true`.
# --instructions--
Додайте оператора абсолютної нерівності до команди `if`, щоб функція визначила рядок `Not Equal`, коли `val` не є абсолютно рівним `17`
Add the strict inequality operator to the `if` statement so the function will return the string `Not Equal` when `val` is not strictly equal to `17`
# --hints--
`testStrictNotEqual(17)` перетворюється в рядку на `Equal`
`testStrictNotEqual(17)` має повернути рядок `Equal`
```js
assert(testStrictNotEqual(17) === 'Equal');
```
`testStrictNotEqual("17")` перетворюється в рядку на `Not Equal`
`testStrictNotEqual("17")` має повернути рядок `Not Equal`
```js
assert(testStrictNotEqual('17') === 'Not Equal');
```
`testStrictNotEqual(12)` перетворюється в рядку на `Not Equal`
`testStrictNotEqual(12)` має повернути рядок `Not Equal`
```js
assert(testStrictNotEqual(12) === 'Not Equal');
```
`testStrictNotEqual("bob")` перетворюється в рядку на `Not Equal`
`testStrictNotEqual("bob")` має повернути рядок `Not Equal`
```js
assert(testStrictNotEqual('bob') === 'Not Equal');
```
Вам слід використовувати оператора`!==`
You should use the `!==` operator
```js
assert(code.match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0);

View File

@@ -25,32 +25,38 @@ dashedName: concatenating-strings-with-plus-operator
const ourStr = "I come first. " + "I come second.";
```
Рядок ` I come first. I come second.` відображатиметься у консолі.
The string `I come first. I come second.` would be displayed in the console.
# --instructions--
Створіть `myStr` з рядків `This is the start.` й `This is the end.` за допомогою `+` оператору. Обов'язково використовуйте пробіл між двома рядками.
# --hints--
`myStr` повинен мати таке ж значення як і рядок `This is the start. This is the end.`
`myStr` should have a single space character between the two strings.
```js
assert(/start\. This/.test(myStr));
```
`myStr` should have a value of the string `This is the start. This is the end.`
```js
assert(myStr === 'This is the start. This is the end.');
```
Для створення `myStr` потрібно використовувати `+`.
You should use the `+` operator to build `myStr`.
```js
assert(code.match(/(["']).*\1\s*\+\s*(["']).*\2/g));
```
Для створення `myStr` потрібно використати ключове слово `const`.
`myStr` should be created using the `const` keyword.
```js
assert(/const\s+myStr/.test(code));
```
Слід призначити результат для змінної `myStr`.
You should assign the result to the `myStr` variable.
```js
assert(/myStr\s*=/.test(code));

View File

@@ -28,13 +28,19 @@ ourStr += "I come second.";
# --hints--
`myStr` повинен мати значення рядка `This is the first sentence. This is the second sentence.`
`myStr` should have a single space character between the two strings.
```js
assert(/sentence\. This/.test(myStr));
```
`myStr` should have a value of the string `This is the first sentence. This is the second sentence.`
```js
assert(myStr === 'This is the first sentence. This is the second sentence.');
```
Для створення `myStr` потрібно використовувати `+=`.
You should use the `+=` operator to build `myStr`.
```js
assert(code.match(/myStr\s*\+=\s*(["']).*\1/g));

View File

@@ -9,7 +9,7 @@ dashedName: constructing-strings-with-variables
# --description--
Інколи потрібно створити рядок у стилі гри [Mad Libs](https://en.wikipedia.org/wiki/Mad_Libs). Використовуючи оператор об'єднання (`+`), можна вставити одну або декілька змінних у рядок, який ви створюєте.
Sometimes you will need to build a string. Використовуючи оператор об'єднання (`+`), можна вставити одну або декілька змінних у рядок, який ви створюєте.
Наприклад:

View File

@@ -9,7 +9,7 @@ dashedName: counting-cards
# --description--
У казино грі Blackjack гравець може здобути перевагу над казино, відстежуючи відносне число старших та молодших карт, що залишились в колоді. Це називається [Підрахунок карт](https://en.wikipedia.org/wiki/Card_counting).
In the casino game Blackjack, a player can determine whether they have an advantage on the next hand over the house by keeping track of the relative number of high and low cards remaining in the deck. This is called Card Counting.
Чим більше старших карт у колоді, тим краще для гравця. Кожній карті присвоєно значення відповідно до нижчеподаної таблиці. Коли рахунок є більшим за нуль, гравець повинен ставити старшу карту. Коли рахунок дорівнює нулю або є меншим, гравець повинен ставити молодшу карту.
@@ -25,7 +25,20 @@ dashedName: counting-cards
# --hints--
Послідовність карт 2, 3, 4, 5, 6 має повернути рядок `5 Bet`
Your function should return a value for count and the text (`Bet` or `Hold`) with one space character between them.
```js
assert(//
(function () {
count = 0;
let out = cc(10);
const hasSpace = /-?\d+ (Bet|Hold)/.test('' + out);
return hasSpace;
})()
);
```
Cards Sequence 2, 3, 4, 5, 6 should return the string `5 Bet`
```js
assert(
@@ -44,7 +57,7 @@ assert(
);
```
Послідовність карт 7, 8, 9 має повернути рядок `0 Hold`
Cards Sequence 7, 8, 9 should return the string `0 Hold`
```js
assert(
@@ -61,7 +74,7 @@ assert(
);
```
Послідовність карт 10, J, Q, K, A має повернути рядок `-5 Hold`
Cards Sequence 10, J, Q, K, A should return the string `-5 Hold`
```js
assert(
@@ -80,7 +93,7 @@ assert(
);
```
Послідовність карт 3, 7, Q, 8, A має повернути рядок `-1 Hold`
Cards Sequence 3, 7, Q, 8, A should return the string `-1 Hold`
```js
assert(
@@ -99,7 +112,7 @@ assert(
);
```
Послідовність карт 2, J, 9, 2, 7 має повернути рядок `1 Bet`
Cards Sequence 2, J, 9, 2, 7 should return the string `1 Bet`
```js
assert(
@@ -118,7 +131,7 @@ assert(
);
```
Послідовність карт 2, 2, 10 має повернути рядок `1 Bet`
Cards Sequence 2, 2, 10 should return the string `1 Bet`
```js
assert(
@@ -135,7 +148,7 @@ assert(
);
```
Послідовність карт 3, 2, A, 10, K має повернути рядок `-1 Hold`
Cards Sequence 3, 2, A, 10, K should return the string `-1 Hold`
```js
assert(

View File

@@ -11,7 +11,7 @@ dashedName: create-decimal-numbers-with-javascript
Ми можемо зберігати десяткові числа також і у змінних. Десяткові числа іноді називаються числами <dfn>floating point</dfn> або <dfn>floats</dfn>.
**Примітка:** Не всі дійсні числа можуть бути віднесені до <dfn>рухомої коми</dfn>. Це може призвести до помилок заокруглення. [Детальніше Тут](https://en.wikipedia.org/wiki/Floating-point_arithmetic#Accuracy_problems).
**Note:** when you compute numbers, they are computed with finite precision. Operations using floating points may lead to different results than the desired outcome. If you are getting one of these results, open a topic on the <a href="https://forum.freecodecamp.org/" target="_blank" rel="noopener noreferrer nofollow">freeCodeCamp forum</a>.
# --instructions--

View File

@@ -21,49 +21,49 @@ FAV_PET = "Dogs";
Змінні, які не передбачають перепризначення, слід називати, використовуючи ключове слово `const`. Це може знадобитися, якщо ви випадково спробуєте перепризначити змінну, яка повинна бути константною.
Як правило, назву пишуть великими літерами, а слова виокремлюють знаком підкреслення.
**Зверніть увагу:** Зазвичай, розробники пишуть назву ідентифікаторів незмінних значень великими літерами, а назви змінних значень (об'єктів та масивів) — маленькими літерами або через camelCase. Ви дізнаєтесь більше про предмети, масиви, незмінні та незмінні цінності в наступних завданнях. Також у наступних завданнях ви побачите приклади використання нижнього та верхнього регістру, а також ідентифікаторів змінної camelCase.
**Note:** It is common for developers to use uppercase variable identifiers for immutable values and lowercase or camelCase for mutable values (objects and arrays). You will learn more about objects, arrays, and immutable and mutable values in later challenges. Also in later challenges, you will see examples of uppercase, lowercase, or camelCase variable identifiers.
# --instructions--
Змініть код так, щоб усі змінні були оголошені за допомогою `let` або `const`. Використовуйте `let` для змінних значень, а `const` для незмінних значень. Крім того, змініть назву змінної, оголошеної з `const`, відповідно до поширених методів роботи: назви констант мають писатися великими літерами.
Change the code so that all variables are declared using `let` or `const`. Use `let` when you want the variable to change, and `const` when you want the variable to remain constant. Also, rename variables declared with `const` to conform to common practices. Do not change the strings assigned to the variables.
# --hints--
`var` має бути відсутнім у коді.
`var` should not exist in your code.
```js
(getUserInput) => assert(!getUserInput('index').match(/var/g));
assert.notMatch(code, /var/g);
```
Ви повинні змінити `fCC` на верхні регістри.
You should change `fCC` to all uppercase.
```js
(getUserInput) => {
assert(getUserInput('index').match(/(FCC)/));
assert(!getUserInput('index').match(/fCC/));
}
assert.match(code, /(FCC)/);
assert.notMatch(code, /(fCC)/);
```
`FCC` має бути константною змінною, оголошеною з `const`.
`FCC` should be a constant variable declared with `const`.
```js
assert.equal(FCC, 'freeCodeCamp');
assert.match(code, /const\s+FCC/);
```
`fact` має оголошуватися з `let`.
The string assigned to `FCC` should not be changed.
```js
(getUserInput) => assert(getUserInput('index').match(/(let fact)/g));
assert.equal(FCC, 'freeCodeCamp');
```
`console.log` необхідно змінити, щоб вивести на екран змінні `FCC` та `fact`.
`fact` should be declared with `let`.
```js
(getUserInput) =>
assert(getUserInput('index').match(/console\.log\(\s*FCC\s*\,\s*fact\s*\)\s*;?/g));
assert.match(code, /(let\s+fact)/g);
```
`console.log` should be changed to print the `FCC` and `fact` variables.
```js
assert.match(code, /console\.log\(\s*FCC\s*\,\s*fact\s*\)\s*;?/g);
```
# --seed--

View File

@@ -38,18 +38,22 @@ assert(myVar === 10);
`myVar = myVar - 1;` слід змінити.
```js
assert(
/let\s*myVar\s*=\s*11;\s*\/*.*\s*([-]{2}\s*myVar|myVar\s*[-]{2});/.test(code)
);
assert(!code.match(/myVar\s*=\s*myVar\s*[-]\s*1.*?;?/));
```
Вам слід користуватись оператором `--` у `myVar`.
You should not assign `myVar` with `10`.
```js
assert(!code.match(/myVar\s*=\s*10.*?;?/));
```
You should use the `--` operator on `myVar`.
```js
assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code));
```
Не слід змінювати код над зазначеним коментарем.
You should not change code above the specified comment.
```js
assert(/let myVar = 11;/.test(code));

View File

@@ -37,12 +37,6 @@ assert(code.match(/quotient/g).length === 1);
# --seed--
## --after-user-code--
```js
(function(y){return 'quotient = '+y;})(quotient);
```
## --seed-contents--
```js

View File

@@ -11,12 +11,12 @@ dashedName: escape-sequences-in-strings
Лапки - не єдині символи, що можуть бути <dfn>екрановані</dfn> в рядку. Існує дві причини використовувати екрановані символи:
1. Щоб дозволити вам використовувати символи, які ви не можете інакше вводити, такі як повернення каретки.
1. To allow you to use characters you may not otherwise be able to type out, such as a newline.
2. Щоб дозволити вам відобразити декілька лапок в рядку без неправильного тлумачення JavaScript того, що ви маєте на увазі.
Ми вивчили це в попередньому завданні.
<table class='table table-striped'><thead><tr><th>Код</th><th>При виведенні буде</th></tr></thead><tbody><tr><td><code>\'</code></td><td>одинарні лапки</td></tr><tr><td><code>\"</code></td><td>подвійні лапки</td></tr><tr><td><code>\\</code></td><td>зворотня коса риска</td></tr><tr><td><code>\n</code></td><td>новий рядок</td></tr><tr><td><code>\r</code></td><td>повернення каретки</td></tr><tr><td><code>\t</code></td><td>вкладка</td></tr><tr><td><code>\b</code></td><td>границі слова</td></tr><tr><td><code>\f</code></td><td>розрив сторінки</td></tr></tbody></table>
<table class='table table-striped'><thead><tr><th>Код</th><th>При виведенні буде</th></tr></thead><tbody><tr><td><code>\'</code></td><td>одинарні лапки</td></tr><tr><td><code>\"</code></td><td>подвійні лапки</td></tr><tr><td><code>\\</code></td><td>зворотня коса риска</td></tr><tr><td><code>\n</code></td><td>новий рядок</td></tr><tr><td><code>\t</code></td><td>tab</td></tr><tr><td><code>\r</code></td><td>carriage return</td></tr><tr><td><code>\b</code></td><td>границі слова</td></tr><tr><td><code>\f</code></td><td>розрив сторінки</td></tr></tbody></table>
*Зверніть увагу, що сама зворотня коса риска повинна бути екранована для того, щоб вона відображалась.*
@@ -78,14 +78,6 @@ assert(myStr === 'FirstLine\n\t\\SecondLine\nThirdLine');
# --seed--
## --after-user-code--
```js
(function(){
if (myStr !== undefined){
console.log('myStr:\n' + myStr);}})();
```
## --seed-contents--
```js

View File

@@ -39,7 +39,7 @@ I am a "double quoted" string inside "double quotes".
assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2);
```
Змінний myStr повинен містити рядок: `I am a "double quoted" string inside "double quotes".`
Variable `myStr` should contain the string: `I am a "double quoted" string inside "double quotes".`
```js
assert(/I am a "double quoted" string inside "double quotes(\."|"\.)$/.test(myStr));

View File

@@ -15,13 +15,13 @@ dashedName: find-the-length-of-a-string
console.log("Alan Peter".length);
```
У консолі відображатиметься значення `10`.
The value `10` would be displayed in the console. Note that the space character between "Alan" and "Peter" is also counted.
Наприклад, якби ми створили змінну `const firstName = "Ada"`, ми б змогли визначити довжину рядка `Ada` за допомогою властивості `firstName.length`.
# --instructions--
Використовуйте властивість `.length`, щоб вирахувати кількість символів у змінній `lastName` і призначити її до `lastNameLength`.
Use the `.length` property to set `lastNameLength` to the number of characters in `lastName`.
# --hints--

View File

@@ -13,7 +13,7 @@ dashedName: generate-random-fractions-with-javascript
JavaScript має функцію `Math.random()`, що генерує випадкові десяткові числа між `0` (включно) and `1` (виключно). Таким чином `Math.random()` може повернути `0` але ніколи не поверне `1`.
**Примітка:** Як [Storing Values with the Assignment Operator](/learn/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator), всі виклики функцій будуть вирішені до того, як `return` виконується, тому ми можемо повернути значення `return` функції `Math.random()`.
**Note:** Like <a href="/learn/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank" rel="noopener noreferrer nofollow">Storing Values with the Assignment Operator</a>, all function calls will be resolved before the `return` executes, so we can `return` the value of the `Math.random()` function.
# --instructions--

View File

@@ -17,7 +17,7 @@ dashedName: global-scope-and-functions
Використовуючи `let` чи `const`, визначте глобальну змінну `myGlobal` поза будь-якою функцією. Привласніть їй значення `10`.
Призначте `5` для `oopsGlobal` всередині функції `fun1` ***не*** використовуючи ключове слово `let` чи `const`.
Inside function `fun1`, assign `5` to `oopsGlobal` ***without*** using the `var`, `let` or `const` keywords.
# --hints--

View File

@@ -9,7 +9,7 @@ dashedName: golf-code
# --description--
У грі [гольф](https://en.wikipedia.org/wiki/Golf), кожен отвір має `par`, значення від середньої кількості очікуваних `ударів`, які повинен зробити гравець, щоб потрапити м'ячем у лунку, для завершення гри. Залежно від того, на скільки вище або нижче `par` є ваші `удари`, існують різні псевдоніми.
In the game of Golf, each hole has a `par`, meaning, the average number of `strokes` a golfer is expected to make in order to sink the ball in the hole to complete the play. Залежно від того, на скільки вище або нижче `par` є ваші `удари`, існують різні псевдоніми.
Ваша функція проходитиме аргументи `par` та `strokes`. Поверніть правильний рядок відповідно до цієї таблиці, яка перелічує удари в порядку пріоритету; зверху (найвищий) до низу (найнижчий):

View File

@@ -31,12 +31,6 @@ assert(/var\s+a\s*=\s*9(\s*;?\s*)$/.test(code));
# --seed--
## --after-user-code--
```js
if(typeof a !== 'undefined') {(function(a){return "a = " + a;})(a);} else { (function() {return 'a is undefined';})(); }
```
## --seed-contents--
```js

View File

@@ -21,7 +21,7 @@ do {
} while (i < 5);
```
Приклад вище поводиться аналогічно з іншими типами циклів, і результуючий масив буде виглядати як `[0, 1, 2, 3, 4]`. Однак, що відрізняє `do...while` від інших циклів, так це те, як він поводиться, коли умова підводить при першій перевірці. Давайте розглянемо це в дії: Ось звичайний `while` цикл, який запустить код за умови, якщо `i < 5`:
Приклад вище поводиться аналогічно з іншими типами циклів, і результуючий масив буде виглядати як `[0, 1, 2, 3, 4]`. Однак, що відрізняє `do...while` від інших циклів, так це те, як він поводиться, коли умова підводить при першій перевірці. Let's see this in action. Here is a regular `while` loop that will run the code in the loop as long as `i < 5`:
```js
const ourArray = [];

View File

@@ -23,7 +23,7 @@ myTest();
console.log(loc);
```
Виклик функції `myTest()` відображатиме рядок `foo` в консолі. Рядок `console.log(loc)` видасть помилку, тому що `loc` не є визначеним за діапазоном функції.
Виклик функції `myTest()` відображатиме рядок `foo` в консолі. The `console.log(loc)` line (outside of the `myTest` function) will throw an error, as `loc` is not defined outside of the function.
# --instructions--

View File

@@ -15,7 +15,7 @@ dashedName: practice-comparing-different-values
**Наприклад:**
`3 == '3'` повертає результат `true` тому, що JavaScript конвертує рядок у число. `3 === '3'` повертає результат false, оскільки ці типи є різними і конвертація не виконується.
`3 == '3'` повертає результат `true` тому, що JavaScript конвертує рядок у число. `3 === '3'` returns `false` because the types are different and type conversion is not performed.
**Примітка:** В JavaScript, ви можете визначити тип змінної або значення за допомогою оператора `typeof`, наступним чином:

View File

@@ -62,12 +62,6 @@ assert(code.match(/"/g).length === 4 && code.match(/'/g).length === 2);
# --seed--
## --after-user-code--
```js
(function() { return "myStr = " + myStr; })();
```
## --seed-contents--
```js

View File

@@ -31,13 +31,13 @@ assert(
);
```
Після `updateRecords(recordCollection, 5439, "tracks", "Take a Chance on Me")`, `tracks` повинні мати рядок `Take a Chance on Me` останнім елементом.
After `updateRecords(recordCollection, 5439, "tracks", "Take a Chance on Me")`, `tracks` should have the string `Take a Chance on Me` as the last and only element.
```js
assert(
updateRecords(_recordCollection, 5439, 'tracks', 'Take a Chance on Me')[5439][
'tracks'
].pop() === 'Take a Chance on Me'
updateRecords(_recordCollection, 5439, 'tracks', 'Take a Chance on Me') &&
_recordCollection[5439]['tracks'].length === 1 &&
_recordCollection[5439]['tracks'].pop() === 'Take a Chance on Me'
);
```

View File

@@ -28,8 +28,8 @@ myFun();
Модифікуйте функцію `abTest` і тому, якщо `a` або `b` дорівнюватиме менше `0`, функція відразу вийде зі значенням `undefined`.
**Підказка**
Пам'ятайте, що [`undefined` - це ключове слово](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables), а не рядок.
**Hint**
Remember that <a href="https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables" target="_blank" rel="noopener noreferrer nofollow"><code>undefined</code> is a keyword</a>, not a string.
# --hints--

View File

@@ -9,7 +9,7 @@ dashedName: returning-boolean-values-from-functions
# --description--
Ви можете пригадати з [Порівняння з оператором рівності](/learn/javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator), що всі порівняльні оператори повертають логічне `true` або `false` значення.
You may recall from <a href="/learn/javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator" target="_blank" rel="noopener noreferrer nofollow">Comparison with the Equality Operator</a> that all comparison operators return a boolean `true` or `false` value.
Інколи люди використовують `if/else` команду для того, щоб зробити порівняння на зразок цього:

View File

@@ -98,7 +98,7 @@ function nextInLine(arr, item) {
}
// Setup
const testArr = [1, 2, 3, 4, 5];
let testArr = [1, 2, 3, 4, 5];
// Display code
console.log("Before: " + JSON.stringify(testArr));
@@ -109,7 +109,7 @@ console.log("After: " + JSON.stringify(testArr));
# --solutions--
```js
const testArr = [1, 2, 3, 4, 5];
let testArr = [1, 2, 3, 4, 5];
function nextInLine(arr, item) {
arr.push(item);

View File

@@ -11,14 +11,14 @@ dashedName: understand-string-immutability
У JavaScript, `String` значення <dfn>immutable</dfn>, означає, що їх не можна буде змінити після створення.
Наприклад, у такому коді:
For example, the following code will produce an error because the letter `B` in the string `Bob` cannot be changed to the letter `J`:
```js
let myStr = "Bob";
myStr[0] = "J";
```
неможливо змінити значення `myStr` на `Job`, тому що вміст `myStr` не може бути зміненим. Зауважте, що *not* означає, що `myStr` не можна змінити, так само як окремі елементи в коді <dfn>string literal</dfn>. Єдиний спосіб змінити `myStr` - це додати новий рядок:
Note that this does *not* mean that `myStr` could not be re-assigned. The only way to change `myStr` would be to assign it with a new value, like this:
```js
let myStr = "Bob";

View File

@@ -9,7 +9,7 @@ dashedName: understanding-uninitialized-variables
# --description--
Коли змінні JavaScript проголошено, вони мають початкове значення `undefined`. Якщо ви виконуєте математичну дію з `undefined` змінної, вашим результатом буде `NaN`, що означає <dfn>"Not a Number"</dfn>. Якщо ви об'єднаєте рядок з `undefined` змінною, ви отримаєте <dfn>рядок</dfn> літерала з `undefined`.
Коли змінні JavaScript проголошено, вони мають початкове значення `undefined`. Якщо ви виконуєте математичну дію з `undefined` змінної, вашим результатом буде `NaN`, що означає <dfn>"Not a Number"</dfn>. If you concatenate a string with an `undefined` variable, you will get a <dfn>string</dfn> of `undefined`.
# --instructions--
@@ -17,19 +17,19 @@ dashedName: understanding-uninitialized-variables
# --hints--
`a` має бути визначене й обчислене, щоб мати значення `6`.
`a` should be defined and have a final value of `6`.
```js
assert(typeof a === 'number' && a === 6);
```
`b` має бути визначене й обчислене, щоб мати значення `15`.
`b` should be defined and have a final value of `15`.
```js
assert(typeof b === 'number' && b === 15);
```
`c` не має містити `undefined` і повинне мати значення рядка `I am a String!`
`c` should not contain `undefined` and should have a final value of the string `I am a String!`
```js
assert(!/undefined/.test(c) && c === 'I am a String!');

View File

@@ -8,7 +8,7 @@ dashedName: use-recursion-to-create-a-countdown
# --description--
У [попередньому завданні](/learn/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion) ви навчилися використовувати рекурсію для заміни циклу `for`. Тепер подивимося на більш складну функцію, яка повертає масив послідовних чисел, починаючи з `1` до числа, переданого функції.
In a <a href="/learn/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion" target="_blank" rel="noopener noreferrer nofollow">previous challenge</a>, you learned how to use recursion to replace a `for` loop. Тепер подивимося на більш складну функцію, яка повертає масив послідовних чисел, починаючи з `1` до числа, переданого функції.
Як уже було згадано в попередньому завданні, це буде <dfn>base case</dfn>. Він повідомляє рекурсивній функції, коли їй більше не потрібно викликати саму себе. Це простий випадок, коли значення, яке повертається, вже відоме. Також існує <dfn>recursive call</dfn>, який виконує початкову функцію з різними параметрами. Якщо функція написана правильно, то буде досягнутий базовий випадок.
@@ -71,6 +71,13 @@ assert(
);
```
Global variables should not be used to cache the array.
```js
countdown(1)
assert.deepStrictEqual(countdown(5), [5, 4, 3, 2, 1]);
```
# --seed--
## --seed-contents--

View File

@@ -56,6 +56,13 @@ assert.deepStrictEqual(rangeOfNumbers(6, 9), [6, 7, 8, 9]);
assert.deepStrictEqual(rangeOfNumbers(4, 4), [4]);
```
Global variables should not be used to cache the array.
```js
rangeOfNumbers(1, 3)
assert.deepStrictEqual(rangeOfNumbers(6, 9), [6, 7, 8, 9]);
```
# --seed--
## --seed-contents--

View File

@@ -25,14 +25,14 @@ const alpha = {
26:"A"
};
alpha[2];
alpha[24];
const thirdLetter = alpha[2];
const lastLetter = alpha[24];
const value = 2;
alpha[value];
const valueLookup = alpha[value];
```
`alpha[2]` - це рядок `Y`, `alpha[24]` - це рядок `C`, а `alpha[value]` - це рядок `Y`.
`thirdLetter` is the string `Y`, `lastLetter` is the string `C`, and `valueLookup` is the string `Y`.
# --instructions--

View File

@@ -9,11 +9,9 @@ dashedName: word-blanks
# --description--
Тепер ми використаємо наші знання про рядки, щоб створити стильну гру у слова [Mad Libs](https://en.wikipedia.org/wiki/Mad_Libs), яку ми називаємо "Пропуски в словах". Ви створите (за бажанням гумористичні) речення типу "Заповніть пропуски".
You are provided sentences with some missing words, like nouns, verbs, adjectives and adverbs. You then fill in the missing pieces with words of your choice in a way that the completed sentence makes sense.
У грі "Пропуски в словах", у вас є речення з пропущеними частинами мови, наприклад, іменниками, дієсловами, прикметниками та прислівниками. Потім ви заповнюєте вибрані вами відсутні фрагменти слів так, аби завершене реченням мало сенс.
Розгляньте це речення - Було дуже **\_\_\_\_**, і ми **\_\_\_\_** себе **\_\_\_\_**. У цьому реченні відсутні три фрагменти: прикметник, дієслово та прислівник; ми можемо додати вибрані нами слова для того, щоб завершити його. Потім ми можемо призначити надіслане речення змінній наступним чином:
Consider this sentence - It was really **\_\_\_\_**, and we **\_\_\_\_** ourselves **\_\_\_\_**. This sentence has three missing pieces- an adjective, a verb and an adverb, and we can add words of our choice to complete it. We can then assign the completed sentence to a variable as follows:
```js
const sentence = "It was really " + "hot" + ", and we " + "laughed" + " ourselves " + "silly" + ".";
@@ -21,11 +19,11 @@ const sentence = "It was really " + "hot" + ", and we " + "laughed" + " ourselve
# --instructions--
У цьому завданні у вас є іменник, дієслово, прикметник та прислівник. Вам потрібно створити завершене речення зі словами на ваш вибір, а також використати ті, які ми надаємо.
In this challenge, we provide you with a noun, a verb, an adjective and an adverb. You need to form a complete sentence using words of your choice, along with the words we provide.
Вам потрібно використати рядок оператор конкатенації `+`, щоб створити новий, за допомогою наданих змінних: `myNoun`, `myAdjective`, `myVerb`, і `myAdverb`. Потім ви задасте сформованому рядку змінну `wordBlanks`. Не слід змінювати слова, які зазначені як змінні.
You will need to use the string concatenation operator `+` to build a new string, using the provided variables: `myNoun`, `myAdjective`, `myVerb`, and `myAdverb`. You will then assign the formed string to the `wordBlanks` variable. You should not change the words assigned to the variables.
Вам також потрібно враховувати пропуски у вашому рядку для того, щоб кінцеве речення містило пробіли між усіма словами. У результаті ви маєте отримати завершене речення.
You will also need to account for spaces in your string, so that the final sentence has spaces between all the words. The result should be a complete sentence.
# --hints--
@@ -35,7 +33,7 @@ const sentence = "It was really " + "hot" + ", and we " + "laughed" + " ourselve
assert(typeof wordBlanks === 'string');
```
Ви не повинні змінювати значення, задані як `myNoun`, `myVerb`, `myAdjective` або `myAdverb`.
You should not change the values assigned to `myNoun`, `myVerb`, `myAdjective` or `myAdverb`.
```js
assert(
@@ -46,7 +44,7 @@ assert(
);
```
Ви не повинні безпосередньо використовувати змінні `собака`, `біг`, `великий`, або `швидко` для того, щоб створити `wordBlanks`.
You should not directly use the values `dog`, `ran`, `big`, or `quickly` to create `wordBlanks`.
```js
const newCode = removeAssignments(code);
@@ -58,7 +56,7 @@ assert(
);
```
`wordBlanks` має містити всі слова, які задані як змінні: `myNoun`, `myVerb`, `myAdjective` і `myAdverb` виокремленими словами, які не є символами (а також будь-якими додатковими словами у вашій madlib).
`wordBlanks` should contain all of the words assigned to the variables `myNoun`, `myVerb`, `myAdjective` and `myAdverb` separated by non-word characters (and any additional words of your choice).
```js
assert(