mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
chore(i18n,learn): processed translations (#48532)
This commit is contained in:
+2
-2
@@ -23,8 +23,8 @@ const article = {
|
||||
"createdAt": "NOVEMBER 28, 2018"
|
||||
};
|
||||
|
||||
const articleAuthor = article[author];
|
||||
const articleLink = article[link];
|
||||
const articleAuthor = article["author"];
|
||||
const articleLink = article["link"];
|
||||
|
||||
const value = "title";
|
||||
const valueLookup = article[value];
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ dashedName: use-the-filter-method-to-extract-data-from-an-array
|
||||
|
||||
Array function أخر مفيد هو `Array.prototype.filter()`أو ببساطة `filter()`.
|
||||
|
||||
`filter` يستدعي function على كل عنصر من array ويعيد array جديدة تحتوي فقط على العناصر التي ترجع لها هذه الدالة `true`. وبعبارة أخرى، تقوم بتصفية ال array، استنادا إلى ال function التي مررت إليها. مثل `map`، تقوم بذلك دون الحاجة إلى تعديل ال array الأصلية.
|
||||
`filter` calls a function on each element of an array and returns a new array containing only the elements for which that function returns a truthy value - that is, a value which returns `true` if passed to the `Boolean()` constructor. وبعبارة أخرى، تقوم بتصفية ال array، استنادا إلى ال function التي مررت إليها. مثل `map`، تقوم بذلك دون الحاجة إلى تعديل ال array الأصلية.
|
||||
|
||||
الـ callback function تقبل ثلاث arguments. وال argument الأولى هي العنصر الحالي الذي تجري معالجته. والثاني هو فهرس ذلك العنصر والثالث هو ال array التي تم على أساسها استدعاء `filter`.
|
||||
|
||||
|
||||
-5
@@ -112,12 +112,7 @@ assert.deepEqual(
|
||||
|
||||
```js
|
||||
function whatIsInAName(collection, source) {
|
||||
const arr = [];
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return arr;
|
||||
}
|
||||
|
||||
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ assert(document.querySelector('main'));
|
||||
assert(code.match(/<\/main\>/));
|
||||
```
|
||||
|
||||
Your `main` element's opening tag should be below the `body` element's opening tag. لقد وضعتهم بترتيب خاطئ.
|
||||
يجب أن تكون العلامة الافتتاحية لعنصر `main` الخاص بك أسفل العلامة الافتتاحية لعنصر `body`. لقد وضعتهم بترتيب خاطئ.
|
||||
|
||||
```js
|
||||
const main = document.querySelector('main');
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ dashedName: step-69
|
||||
<meta attribute="value">
|
||||
```
|
||||
|
||||
Tell the browser to parse the markup into multiple languages by creating a `meta` element as a child of the `head` element. عيّن سمة `charset` إلى `UTF-8`.
|
||||
أخبر المتصفح بتحليل التشكيل (markdown) إلى لغات متعددة عن طريق إنشاء `meta` كعنصر فرعي في عنصر `head`. عيّن سمة `charset` إلى `UTF-8`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@ const article = {
|
||||
"createdAt": "NOVEMBER 28, 2018"
|
||||
};
|
||||
|
||||
const articleAuthor = article[author];
|
||||
const articleLink = article[link];
|
||||
const articleAuthor = article["author"];
|
||||
const articleLink = article["link"];
|
||||
|
||||
const value = "title";
|
||||
const valueLookup = article[value];
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ dashedName: use-the-filter-method-to-extract-data-from-an-array
|
||||
|
||||
另一個有用的數組方法是 `filter()`(即 `Array.prototype.filter()`)。
|
||||
|
||||
`filter` 接收一個回調函數,將回調函數內的邏輯應用於數組的每個元素,新數組包含根據回調函數內條件返回 `true` 的元素。 換言之,它根據傳遞給它的函數過濾數組。 和 `map` 一樣,filter 不會改變原始數組。
|
||||
`filter` calls a function on each element of an array and returns a new array containing only the elements for which that function returns a truthy value - that is, a value which returns `true` if passed to the `Boolean()` constructor. 換言之,它根據傳遞給它的函數過濾數組。 和 `map` 一樣,filter 不會改變原始數組。
|
||||
|
||||
回調函數接收三個參數。 第一個參數是當前正在被處理的元素。 第二個參數是這個元素的索引,第三個參數是在其上調用 `filter` 方法的數組。
|
||||
|
||||
|
||||
-5
@@ -112,12 +112,7 @@ assert.deepEqual(
|
||||
|
||||
```js
|
||||
function whatIsInAName(collection, source) {
|
||||
const arr = [];
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return arr;
|
||||
}
|
||||
|
||||
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@ const article = {
|
||||
"createdAt": "NOVEMBER 28, 2018"
|
||||
};
|
||||
|
||||
const articleAuthor = article[author];
|
||||
const articleLink = article[link];
|
||||
const articleAuthor = article["author"];
|
||||
const articleLink = article["link"];
|
||||
|
||||
const value = "title";
|
||||
const valueLookup = article[value];
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ dashedName: use-the-filter-method-to-extract-data-from-an-array
|
||||
|
||||
另一个有用的数组方法是 `filter()`(即 `Array.prototype.filter()`)。
|
||||
|
||||
`filter` 接收一个回调函数,将回调函数内的逻辑应用于数组的每个元素,新数组包含根据回调函数内条件返回 `true` 的元素。 换言之,它根据传递给它的函数过滤数组。 和 `map` 一样,filter 不会改变原始数组。
|
||||
`filter` calls a function on each element of an array and returns a new array containing only the elements for which that function returns a truthy value - that is, a value which returns `true` if passed to the `Boolean()` constructor. 换言之,它根据传递给它的函数过滤数组。 和 `map` 一样,filter 不会改变原始数组。
|
||||
|
||||
回调函数接收三个参数。 第一个参数是当前正在被处理的元素。 第二个参数是这个元素的索引,第三个参数是在其上调用 `filter` 方法的数组。
|
||||
|
||||
|
||||
-5
@@ -112,12 +112,7 @@ assert.deepEqual(
|
||||
|
||||
```js
|
||||
function whatIsInAName(collection, source) {
|
||||
const arr = [];
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return arr;
|
||||
}
|
||||
|
||||
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@ const article = {
|
||||
"createdAt": "NOVEMBER 28, 2018"
|
||||
};
|
||||
|
||||
const articleAuthor = article[author];
|
||||
const articleLink = article[link];
|
||||
const articleAuthor = article["author"];
|
||||
const articleLink = article["link"];
|
||||
|
||||
const value = "title";
|
||||
const valueLookup = article[value];
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ dashedName: use-the-filter-method-to-extract-data-from-an-array
|
||||
|
||||
Otra función útil de los arreglos es `Array.prototype.filter()` o simplemente `filter()`.
|
||||
|
||||
`filter` llama a una función en cada elemento de un arreglo y devuelve un nuevo arreglo que contiene solo los elementos por lo que esa función devuelve `true`. En otras palabras, filtra el arreglo, basándose en la función que se le pasa. Al igual que `map`, hace esto sin necesidad de modificar el arreglo original.
|
||||
`filter` calls a function on each element of an array and returns a new array containing only the elements for which that function returns a truthy value - that is, a value which returns `true` if passed to the `Boolean()` constructor. En otras palabras, filtra el arreglo, basándose en la función que se le pasa. Al igual que `map`, hace esto sin necesidad de modificar el arreglo original.
|
||||
|
||||
La función callback acepta tres argumentos. El primer argumento es el elemento actual que se está procesando. El segundo es el índice de ese elemento y el tercero es el arreglo sobre el que se llamó al método `filter`.
|
||||
|
||||
|
||||
-5
@@ -112,12 +112,7 @@ assert.deepEqual(
|
||||
|
||||
```js
|
||||
function whatIsInAName(collection, source) {
|
||||
const arr = [];
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return arr;
|
||||
}
|
||||
|
||||
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@ const article = {
|
||||
"createdAt": "NOVEMBER 28, 2018"
|
||||
};
|
||||
|
||||
const articleAuthor = article[author];
|
||||
const articleLink = article[link];
|
||||
const articleAuthor = article["author"];
|
||||
const articleLink = article["link"];
|
||||
|
||||
const value = "title";
|
||||
const valueLookup = article[value];
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ dashedName: use-the-filter-method-to-extract-data-from-an-array
|
||||
|
||||
Eine weitere nützliche Array-Funktion ist `Array.prototype.filter()`, oder einfach `filter()`.
|
||||
|
||||
`filter` ruft eine Funktion für jedes Element eines Arrays auf und gibt ein neues Array zurück, das nur die Elemente enthält, für die die Funktion `true` zurückgibt. Mit anderen Worten: Sie filtert das Array auf der Grundlage der übergebenen Funktion. Genau wie `map` macht sie das, ohne dass das ursprüngliche Array verändert werden muss.
|
||||
`filter` calls a function on each element of an array and returns a new array containing only the elements for which that function returns a truthy value - that is, a value which returns `true` if passed to the `Boolean()` constructor. Mit anderen Worten: Sie filtert das Array auf der Grundlage der übergebenen Funktion. Genau wie `map` macht sie das, ohne dass das ursprüngliche Array verändert werden muss.
|
||||
|
||||
Die Callback-Funktion nimmt drei Argumente entgegen. Das erste Argument ist das aktuelle Element, das bearbeitet wird. Das zweite ist der Index dieses Elements und das dritte ist das Array, auf dem die Methode `filter` aufgerufen wurde.
|
||||
|
||||
|
||||
-5
@@ -112,12 +112,7 @@ assert.deepEqual(
|
||||
|
||||
```js
|
||||
function whatIsInAName(collection, source) {
|
||||
const arr = [];
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return arr;
|
||||
}
|
||||
|
||||
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@ const article = {
|
||||
"createdAt": "NOVEMBER 28, 2018"
|
||||
};
|
||||
|
||||
const articleAuthor = article[author];
|
||||
const articleLink = article[link];
|
||||
const articleAuthor = article["author"];
|
||||
const articleLink = article["link"];
|
||||
|
||||
const value = "title";
|
||||
const valueLookup = article[value];
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ dashedName: use-the-filter-method-to-extract-data-from-an-array
|
||||
|
||||
Un'altra funzione utile con gli array è `Array.prototype.filter()`, o semplicemente `filter()`.
|
||||
|
||||
`filter` chiama una funzione su ogni elemento di un array e restituisce un nuovo array contenente solo gli elementi per i quali questa funzione restituisce `true`. In altre parole, filtra l'array, sulla base della funzione passata ad esso. Come `map`, lo fa senza dover modificare l'array originale.
|
||||
`filter` calls a function on each element of an array and returns a new array containing only the elements for which that function returns a truthy value - that is, a value which returns `true` if passed to the `Boolean()` constructor. In altre parole, filtra l'array, sulla base della funzione passata ad esso. Come `map`, lo fa senza dover modificare l'array originale.
|
||||
|
||||
La funzione callback accetta tre argomenti. Il primo argomento è l'elemento che è correntemente in fase di elaborazione. Il secondo è l'indice di quell'elemento e il terzo è l'array su cui è stato chiamato il metodo `filter`.
|
||||
|
||||
|
||||
-5
@@ -112,12 +112,7 @@ assert.deepEqual(
|
||||
|
||||
```js
|
||||
function whatIsInAName(collection, source) {
|
||||
const arr = [];
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return arr;
|
||||
}
|
||||
|
||||
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ Puoi impostare il comportamento del browser aggiungendo degli elementi `meta` au
|
||||
<meta attribute="value">
|
||||
```
|
||||
|
||||
Tell the browser to parse the markup into multiple languages by creating a `meta` element as a child of the `head` element. Imposta l'attributo `charset` su `UTF-8`.
|
||||
Ordina al browser di interpretare il markup in linguaggi multipli creando un elemento `meta` come figlio dell'elemento `head`. Imposta l'attributo `charset` su `UTF-8`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@ const article = {
|
||||
"createdAt": "NOVEMBER 28, 2018"
|
||||
};
|
||||
|
||||
const articleAuthor = article[author];
|
||||
const articleLink = article[link];
|
||||
const articleAuthor = article["author"];
|
||||
const articleLink = article["link"];
|
||||
|
||||
const value = "title";
|
||||
const valueLookup = article[value];
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ dashedName: use-the-filter-method-to-extract-data-from-an-array
|
||||
|
||||
もう一つの便利な配列関数に、`Array.prototype.filter()`、または単に `filter()` があります。
|
||||
|
||||
`filter` は配列の各要素に対して関数を呼び出し、その関数が `true` を返す要素のみを含む新しい配列を返します。 つまり、渡された関数に基づいて配列をフィルターで絞り込みます。 `map` と同様に、元の配列を変更せずにこうした操作を実行します。
|
||||
`filter` calls a function on each element of an array and returns a new array containing only the elements for which that function returns a truthy value - that is, a value which returns `true` if passed to the `Boolean()` constructor. つまり、渡された関数に基づいて配列をフィルターで絞り込みます。 `map` と同様に、元の配列を変更せずにこうした操作を実行します。
|
||||
|
||||
コールバック関数は 3 つの引数を受け取ります。 最初の引数は、現在処理中の要素です。 2 つ目は、その要素のインデックスです。3 つ目は、`filter` メソッドを呼び出した対象の配列です。
|
||||
|
||||
|
||||
-5
@@ -112,12 +112,7 @@ assert.deepEqual(
|
||||
|
||||
```js
|
||||
function whatIsInAName(collection, source) {
|
||||
const arr = [];
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return arr;
|
||||
}
|
||||
|
||||
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@ const article = {
|
||||
"createdAt": "NOVEMBER 28, 2018"
|
||||
};
|
||||
|
||||
const articleAuthor = article[author];
|
||||
const articleLink = article[link];
|
||||
const articleAuthor = article["author"];
|
||||
const articleLink = article["link"];
|
||||
|
||||
const value = "title";
|
||||
const valueLookup = article[value];
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ dashedName: use-the-filter-method-to-extract-data-from-an-array
|
||||
|
||||
Outra função útil de array é `Array.prototype.filter()`, ou simplesmente `filter()`.
|
||||
|
||||
O `filter` chama uma função para cada elemento de um array e constrói um novo array contendo apenas os elementos para os quais a função retorna `true`. Em outras palavras, ele filtra o array de acordo com a função passada a ele. Ele o faz sem alterar o array original assim como `map`.
|
||||
`filter` chama uma função em cada elemento de um array e retorna um novo array contendo apenas os elementos para os quais aquela função retorna um valor verdadeiro - ou seja, um valor que retorna `true` se passada para o construtor `Boolean()`. Em outras palavras, ele filtra o array de acordo com a função passada a ele. Ele o faz sem alterar o array original assim como `map`.
|
||||
|
||||
A função de callback toma três argumentos. O primeiro argumento é o elemento que está a ser processado. O segundo é o índice deste elemento e o terceiro é o array do qual `filter` foi chamado.
|
||||
|
||||
|
||||
-5
@@ -112,12 +112,7 @@ assert.deepEqual(
|
||||
|
||||
```js
|
||||
function whatIsInAName(collection, source) {
|
||||
const arr = [];
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return arr;
|
||||
}
|
||||
|
||||
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ dashedName: find-characters-with-lazy-matching
|
||||
|
||||
# --description--
|
||||
|
||||
Em expressões regulares, uma captura <dfn>gananciosa</dfn> encontra a parte mais longa o possível de uma string em que a regex atua e a retorna como resultado. A alternativa se chama captura <dfn>preguiçosa</dfn> e ela encontra o menor pedaço o possível de uma string que satisfaz a regex.
|
||||
Em expressões regulares, uma captura <dfn>gananciosa</dfn> encontra a parte mais longa o possível de uma string em que a regex atua e a retorna como resultado. A alternativa se chama captura <dfn>preguiçosa</dfn> e ela encontra o menor pedaço possível de uma string que satisfaz a regex.
|
||||
|
||||
Você pode aplicar a regex `/t[a-z]*i/` à string `"titanic"`. Essa regex é basicamente um padrão que começa com `t`, termina com `i`e tem algumas letras no meio delas.
|
||||
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@ const article = {
|
||||
"createdAt": "NOVEMBER 28, 2018"
|
||||
};
|
||||
|
||||
const articleAuthor = article[author];
|
||||
const articleLink = article[link];
|
||||
const articleAuthor = article["author"];
|
||||
const articleLink = article["link"];
|
||||
|
||||
const value = "title";
|
||||
const valueLookup = article[value];
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ dashedName: use-the-filter-method-to-extract-data-from-an-array
|
||||
|
||||
Інша зручна формула масиву є `Array.prototype.filter()`, або ж просто `filter()`.
|
||||
|
||||
`filter` викликає функцію в кожному елементі масиву й повертає новий масив, що містить в собі ті елементи, що повертає функція `true`. Іншими словами, він фільтрує масив, на основі функції, яка передана до нього. Як і `map`, це робиться без необхідності зміни початкового масиву.
|
||||
`filter` calls a function on each element of an array and returns a new array containing only the elements for which that function returns a truthy value - that is, a value which returns `true` if passed to the `Boolean()` constructor. Іншими словами, він фільтрує масив, на основі функції, яка передана до нього. Як і `map`, це робиться без необхідності зміни початкового масиву.
|
||||
|
||||
Функція зворотнього виклику приймає три аргументи. Перший аргумент - це поточний елемент, який опрацьовується. Другий є індексом цього елемента, а третій - масивом, на якому було викликано метод `filter`.
|
||||
|
||||
|
||||
-5
@@ -112,12 +112,7 @@ assert.deepEqual(
|
||||
|
||||
```js
|
||||
function whatIsInAName(collection, source) {
|
||||
const arr = [];
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return arr;
|
||||
}
|
||||
|
||||
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ dashedName: step-69
|
||||
<meta attribute="value">
|
||||
```
|
||||
|
||||
Tell the browser to parse the markup into multiple languages by creating a `meta` element as a child of the `head` element. Встановіть його атрибут `charset` на `UTF-8`.
|
||||
Скажіть браузеру аналізувати розмітку кількома мовами, створивши елемент `meta` як дочірній елемент елемента `head`. Встановіть його атрибут `charset` на `UTF-8`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ dashedName: step-75
|
||||
|
||||
# --description--
|
||||
|
||||
Now that you are updating the `gold` and `health` variables, you need to display those new values on the game screen. After your assignment lines, assign the `innerText` property of `goldText` to be the variable `gold`. Use the same pattern to update `healthText` with the `health` variable.
|
||||
Ви оновлюєте змінні `gold` та `health`, і потрібно, щоб на екрані гри зображались нові значення. Після рядків із присвоюванням призначте властивість `innerText` об'єкта `goldText` на змінну `gold`. Використайте той самий шаблон, щоб оновити `healthText` зі змінною `health`.
|
||||
|
||||
Ось приклад:
|
||||
|
||||
@@ -17,7 +17,7 @@ const total = document.querySelector('#total');
|
||||
total.innerText = value;
|
||||
```
|
||||
|
||||
You can test this by clicking your "Go to store" button, followed by your "Buy Health" button.
|
||||
Це можна перевірити, натиснувши кнопку «Go to store», одразу після кнопки «Buy Health».
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ dashedName: step-76
|
||||
|
||||
# --description--
|
||||
|
||||
What if the player doesn't have enough gold to buy health? When you want to run code conditionally, you can use the `if` statement. Put all of the code in your `buyHealth` function inside an `if` statement. Наприклад:
|
||||
Що робити, якщо у гравця недостатньо золота, щоб купити здоров'я? Коли ви хочете умовно запустити код, ви можете використати інструкцію `if`. Помістіть весь код у своїй функції `buyHealth` всередині інструкції `if`. Наприклад:
|
||||
|
||||
```js
|
||||
function myFunction() {
|
||||
@@ -17,7 +17,7 @@ function myFunction() {
|
||||
}
|
||||
```
|
||||
|
||||
For now, follow that pattern to use a string `condition` inside your `if` statement.
|
||||
Наразі дотримуйтесь того шаблону, щоб використати рядок `condition` всередині інструкції `if`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -27,7 +27,7 @@ For now, follow that pattern to use a string `condition` inside your `if` statem
|
||||
assert.match(buyHealth.toString(), /if/);
|
||||
```
|
||||
|
||||
Your `if` statement should have the string `condition` for the condition.
|
||||
Ваша інструкція `if` повинна мати рядок `condition` для умови.
|
||||
|
||||
```js
|
||||
assert.match(buyHealth.toString(), /if\s*\(('|")condition\1\)/);
|
||||
|
||||
+3
-3
@@ -7,13 +7,13 @@ dashedName: step-85
|
||||
|
||||
# --description--
|
||||
|
||||
Increasing a value by 1, or <dfn>incrementing</dfn>, has a special operator in JavaScript: `++`. If you wanted to increase `num` by 1, you could write `num++`.
|
||||
Збільшення значення на 1, або <dfn>інкремент</dfn>, має спеціальний оператор у JavaScript: `++`. Якщо ви хочете збільшити `num` на 1, ви можете написати `num++`.
|
||||
|
||||
Change your `currentWeapon` assignment to use the increment operator.
|
||||
Змініть своє присвоювання `currentWeapon`, щоб використати оператор інкременту.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use the increment operator to increase `currentWeapon` by `1`.
|
||||
Ви повинні використати оператор інкременту, щоб збільшити `currentWeapon` на `1`.
|
||||
|
||||
```js
|
||||
assert.match(buyWeapon.toString(), /currentWeapon\s*\+\s*\+/);
|
||||
|
||||
+5
-5
@@ -7,9 +7,9 @@ dashedName: step-90
|
||||
|
||||
# --description--
|
||||
|
||||
You can insert variables into a string with the <dfn>concatenation operator</dfn> `+`. Update the `You now have a new weapon.` string to say `You now have a` and the name of the new weapon. Не забудьте поставити крапку в кінці речення.
|
||||
Ви можете вставити змінні в рядок за допомогою <dfn>оператора конкатенації</dfn> `+`. Оновіть рядок `You now have a new weapon.` на `You now have a` та назву нової зброї. Не забудьте поставити крапку в кінці речення.
|
||||
|
||||
Here is an example that creates the string `Hello, our name is freeCodeCamp.`:
|
||||
Ось приклад, який створює рядок `Hello, our name is freeCodeCamp.`:
|
||||
|
||||
```js
|
||||
const ourName = "freeCodeCamp";
|
||||
@@ -18,19 +18,19 @@ const ourStr = "Hello, our name is " + ourName + ".";
|
||||
|
||||
# --hints--
|
||||
|
||||
You should update the `text.innerText` assignment to start with the string `You now have a`.
|
||||
Ви повинні оновити присвоювання `text.innerText`, щоб воно починалося з рядка `You now have a`.
|
||||
|
||||
```js
|
||||
assert.match(buyWeapon.toString(), /text\.innerText\s*=\s*('|")You now have a \1/);
|
||||
```
|
||||
|
||||
You should use the concatenation operator to add `newWeapon` to the end of the `text.innerText` string.
|
||||
Ви повинні використати оператор конкатенації, щоб додати `newWeapon` в кінець рядка `text.innerText`.
|
||||
|
||||
```js
|
||||
assert.match(buyWeapon.toString(), /text\.innerText\s*=\s*('|")You now have a \1\s*\+\s*newWeapon/);
|
||||
```
|
||||
|
||||
You should use the concatenation operator to end your `text.innerText` string with a `.`.
|
||||
Ви повинні використати оператор конкатенації, щоб рядок `text.innerText` закінчувався на `.`.
|
||||
|
||||
```js
|
||||
assert.match(buyWeapon.toString(), /text\.innerText\s*=\s*('|")You now have a \1\s*\+\s*newWeapon\s*\+\s*('|")\.\2/);
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ dashedName: step-96
|
||||
|
||||
# --description--
|
||||
|
||||
Arrays have a `length` property that returns the number of items in the array. You may want to add new values to the `weapons` array in the future. Змініть свою умову `if`, щоб перевіряти, чи `currentWeapon` менше за довжину масиву `weapons`. An example of checking the length of an array `myArray` would look like `myArray.length`.
|
||||
Масиви мають властивість `length`, яка повертає кількість об'єктів у масиві. У майбутньому вам доведеться додати нові значення до масиву `weapons`. Змініть свою умову `if`, щоб перевіряти, чи `currentWeapon` менше за довжину масиву `weapons`. Приклад визначення довжини масиву `myArray` виглядатиме як `myArray.length`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+2
-2
@@ -7,11 +7,11 @@ dashedName: step-97
|
||||
|
||||
# --description--
|
||||
|
||||
Тепер у вас є помилка, яку потрібно виправити. The `currentWeapon` variable is the index of the `weapons` array, but array indexing starts at zero. The index of the last element in an array is one less than the length of the array. Змініть умову `if` на перевірку `weapons.length - 1` замість `weapons.length`.
|
||||
Тепер у вас є помилка, яку потрібно виправити. Змінна `currentWeapon` є індексом масиву `weapons`, але індексування масиву починається з нуля. Індекс останнього елемента в масиві на один менший, ніж довжина масиву. Змініть умову `if` на перевірку `weapons.length - 1` замість `weapons.length`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should update the condition to subtract `1` from `weapons.length`.
|
||||
Ви повинні оновити умову на віднімання `1` від `weapons.length`.
|
||||
|
||||
```js
|
||||
assert.match(buyWeapon.toString(), /weapons\.length\s*-\s*1/);
|
||||
|
||||
+6
-6
@@ -7,35 +7,35 @@ dashedName: step-105
|
||||
|
||||
# --description--
|
||||
|
||||
After your `currentWeapon`, use the concatenation operator to set `text.innerText` to the string `You sold a`, then `currentWeapon`, then the string `.`.
|
||||
Після свого `currentWeapon` скористайтеся оператором конкатенації, щоб встановити `text.innerText` на рядок `You sold a`, потім `currentWeapon`, а потім рядок `.`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use the assignment operator with `text.innerText`.
|
||||
Ви повинні використати оператор присвоювання із `text.innerText`.
|
||||
|
||||
```js
|
||||
assert.match(sellWeapon.toString(), /text\.innerText\s*=/);
|
||||
```
|
||||
|
||||
Ви повинні додати `You sold a` до `text.innerText`. Spacing is important.
|
||||
Ви повинні додати `You sold a` до `text.innerText`. Інтервал важливий.
|
||||
|
||||
```js
|
||||
assert.match(sellWeapon.toString(), /text\.innerText\s*=\s*('|")You sold a \1/);
|
||||
```
|
||||
|
||||
Ви повинні додати значення `currentWeapon` до рядка `You sold a`. Use the concatenation operator to do this on the same line.
|
||||
Ви повинні додати значення `currentWeapon` до рядка `You sold a`. Використайте оператор конкатенації, щоб зробити це в тому самому рядку.
|
||||
|
||||
```js
|
||||
assert.match(sellWeapon.toString(), /text\.innerText\s*=\s*('|")You sold a\s\1\s*\+\s*\_currentWeapon/);
|
||||
```
|
||||
|
||||
Ви повинні додати рядок `.` до значення `currentWeapon`. Use the concatenation operator to do this on the same line.
|
||||
Ви повинні додати рядок `.` до значення `currentWeapon`. Використайте оператор конкатенації, щоб зробити це в тому самому рядку.
|
||||
|
||||
```js
|
||||
assert.match(sellWeapon.toString(), /text\.innerText\s*=\s*('|")You sold a \1\s*\+\s*\_currentWeapon\s+\+\s+('|")\.\2/);
|
||||
```
|
||||
|
||||
Your `text.innerText` should update to the proper string.
|
||||
Ваш `text.innerText` повинен оновитися до правильного рядка.
|
||||
|
||||
```js
|
||||
inventory = ["first", "second"];
|
||||
|
||||
+4
-4
@@ -7,11 +7,11 @@ dashedName: step-106
|
||||
|
||||
# --description--
|
||||
|
||||
Now use the `+=` operator to add the string `In your inventory you have:` and the contents of `inventory` to the `text.innerText`. Make sure to include the space at the beginning and end of the `In your inventory you have:` string.
|
||||
Тепер скористайтеся оператором `+=`, щоб додати рядок `In your inventory you have:` та вміст `inventory` до `text.innerText`. Обов’язково додайте пробіл на початку та в кінці рядка `In your inventory you have:`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should add another `text.innerText` line.
|
||||
Ви повинні додати ще один рядок `text.innerText`.
|
||||
|
||||
```js
|
||||
const matches = sellWeapon.toString().match(/text\.innerText/g);
|
||||
@@ -25,13 +25,13 @@ const matches = sellWeapon.toString().match(/text\.innerText\s*\+=/g);
|
||||
assert.equal(matches.length, 1);
|
||||
```
|
||||
|
||||
You should add the string `In your inventory you have:` to the second `text.innerText` line. Spacing matters.
|
||||
Ви повинні додати рядок `In your inventory you have:` до другого рядка `text.innerText`. Інтервал має значення.
|
||||
|
||||
```js
|
||||
assert.match(sellWeapon.toString(), /text\.innerText\s*\+=\s*('|") In your inventory you have: \1/);
|
||||
```
|
||||
|
||||
You should use the concatenation operator to add the value of `inventory` to the end of your second `text.innerText` line.
|
||||
Ви повинні використати оператор конкатенації, щоб додати значення `inventory` в кінець свого другого рядка `text.innerText`.
|
||||
|
||||
```js
|
||||
assert.match(sellWeapon.toString(), /text\.innerText\s*\+=\s*('|") In your inventory you have: \1\s*\+\s*inventory/);
|
||||
|
||||
+4
-4
@@ -7,11 +7,11 @@ dashedName: step-113
|
||||
|
||||
# --description--
|
||||
|
||||
Add a new object to the end of the `locations` array, following the same properties as the rest of the objects. Set `name` to `fight`, `button text` to an array with `Attack`, `Dodge`, and `Run`, `button functions` to an array with `attack`, `dodge`, and `goTown`, and `text` to `You are fighting a monster.`.
|
||||
Додайте новий об’єкт в кінець масиву `locations`, дотримуючись тих самих властивостей, що й в інших об’єктів. Встановіть `name` на `fight`, `button text` на масив із `Attack`, `Dodge` і `Run`, `button functions` на масив із `attack`, `dodge` і `goTown` та `text` на `You are fighting a monster.`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `locations` array should have 4 values in it.
|
||||
Ваш масив `locations` повинен містити 4 значення.
|
||||
|
||||
```js
|
||||
console.log(locations);
|
||||
@@ -30,13 +30,13 @@ assert.isObject(locations[3]);
|
||||
assert.equal(locations[3].name, "fight");
|
||||
```
|
||||
|
||||
Your new object should have a `button text` property set to an array with the strings `Attack`, `Dodge`, and `Run`.
|
||||
Ваш новий об’єкт повинен мати властивість `button text`, налаштовану на масив з рядками `Attack`, `Dodge` та `Run`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[3]["button text"], ["Attack", "Dodge", "Run"]);
|
||||
```
|
||||
|
||||
Your new object should have a `button functions` property set to an array with the variables `attack`, `dodge`, and `goTown`.
|
||||
Ваш новий об’єкт повинен мати властивість `button functions`, налаштовану на масив зі змінними `attack`, `dodge` та `goTown`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[3]["button functions"], [attack, dodge, goTown]);
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ dashedName: step-116
|
||||
|
||||
# --description--
|
||||
|
||||
The HTML element that shows the monster's stats has been hidden with CSS. Display the `monsterStats` element by updating the `display` property of the `style` property to `block`. For example, updating the `first` property of the `name` property of `user` would look like:
|
||||
HTML-елемент, який показує статистику монстра, був прихований за допомогою CSS. Щоб показати елемент `monsterStats`, оновіть властивість `display` властивості `style` на `block`. Наприклад, якщо оновити властивість `first` властивості `name` об'єкта `user`, то вигляд буде такий:
|
||||
|
||||
```js
|
||||
user.name.first = "Naomi";
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ dashedName: step-117
|
||||
|
||||
# --description--
|
||||
|
||||
Now set the `innerText` property of `monsterName` to be the `name` property of the current monster. Do the same for `monsterHealthText` and the `health` property.
|
||||
Тепер встановіть властивість `innerText` об'єкта `monsterName` на властивість `name` поточного монстра. Зробіть те саме для `monsterHealthText` та властивості `health`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -17,7 +17,7 @@ Now set the `innerText` property of `monsterName` to be the `name` property of t
|
||||
assert.match(goFight.toString(), /monsterName\.innerText/);
|
||||
```
|
||||
|
||||
You should set the `innerText` property of `monsterName` to be the `name` value of the current monster. Remember that you can get the current monster with `monsters[fighting]`.
|
||||
Ви повинні встановити властивість `innerText` об'єкта `monsterName` на значення `name` поточного монстра. Це можна зробити за допомогою `monsters[fighting]`.
|
||||
|
||||
```js
|
||||
assert.match(goFight.toString(), /monsterName\.innerText\s*=\s*monsters\[fighting\]\.name/);
|
||||
@@ -29,7 +29,7 @@ assert.match(goFight.toString(), /monsterName\.innerText\s*=\s*monsters\[fightin
|
||||
assert.match(goFight.toString(), /monsterHealthText\.innerText/);
|
||||
```
|
||||
|
||||
You should set the `innerText` property of `monsterHealthText` to be the `health` value of the current monster. Remember that you assigned this value to a `monsterHealth` variable.
|
||||
Ви повинні встановити властивість `innerText` об'єкта `monsterHealthText` на значення `health` поточного монстра. Пам'ятайте, що ви призначили це значення до змінної `monsterHealth`.
|
||||
|
||||
```js
|
||||
assert.match(goFight.toString(), /monsterHealthText\.innerText\s*=\s*monsterHealth/);
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@ dashedName: step-118
|
||||
|
||||
# --description--
|
||||
|
||||
Now you can build the `attack` function. First, update the `text` message to say `The [monster name] attacks.`, replacing `[monster name]` with the name of the monster. Remember you can use the concatenation operator for this.
|
||||
Тепер ви можете побудувати функцію `attack`. Спочатку оновіть повідомлення `text` на `The [monster name] attacks.`, замінивши `[monster name]` на назву монстра. Не забудьте, що ви можете використати оператор конкатенації для цього.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -17,19 +17,19 @@ Now you can build the `attack` function. First, update the `text` message to say
|
||||
assert.match(attack.toString(), /text\.innerText/);
|
||||
```
|
||||
|
||||
You should assign the string `The` to `innerText` property of `text`.
|
||||
Ви повинні присвоїти рядок `The` до властивості `innerText` об'єкта `text`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /text\.innerText\s*=\s*('|")The \1/);
|
||||
```
|
||||
|
||||
You should use the concatenation operator to add the value of `monsters[fighting].name` to the `The` string.
|
||||
Ви повинні використати оператор конкатенації, щоб додати значення `monsters[fighting].name` до рядка `The`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /text\.innerText\s*=\s*('|")The \1\s*\+\s*monsters\[fighting\]\.name/);
|
||||
```
|
||||
|
||||
You should use the concatenation operator to add the string `attacks.` to the `monsters[fighting].name` string.
|
||||
Ви повинні використати оператор конкатенації, щоб додати рядок `attacks.` до рядка `monsters[fighting].name`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /text\.innerText\s*=\s*('|")The \1\s*\+\s*monsters\[fighting\]\.name\s*\+\s*('|") attacks\.\2/);
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@ dashedName: step-119
|
||||
|
||||
# --description--
|
||||
|
||||
On a new line, add the string `You attack it with your [weapon].` to the `text` value, replacing `[weapon]` with the player's current weapon.
|
||||
У новому рядку додайте рядок `You attack it with your [weapon].` до значення `text`, замінивши `[weapon]` на поточну зброю гравця.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -24,19 +24,19 @@ assert.lengthOf(match, 2);
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=/);
|
||||
```
|
||||
|
||||
You should add the string `You attack it with your` to the `text.innerText` value. Пам'ятайте, що інтервал має значення.
|
||||
Ви повинні додати рядок `You attack it with your` до значення `text.innerText`. Пам'ятайте, що інтервал має значення.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|") You attack it with your \1/);
|
||||
```
|
||||
|
||||
You should use the concatenation operator to add the current weapon to the string. You can get the current weapon with `weapons[currentWeapon].name`.
|
||||
Ви повинні використати оператор конкатенації, щоб додати поточну зброю до рядка. Поточну зброю можна отримати за допомогою `weapons[currentWeapon].name`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|") You attack it with your \1\s*\+\s*weapons\[currentWeapon\]\.name/);
|
||||
```
|
||||
|
||||
You should use the concatenation operator to end your string with `.`.
|
||||
Ви повинні використати оператор конкатенації, щоб закінчити рядок з `.`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|") You attack it with your \1\s*\+\s*weapons\[currentWeapon\]\.name\s*\+\s*('|")\.\2/);
|
||||
|
||||
+8
-8
@@ -7,21 +7,21 @@ dashedName: step-122
|
||||
|
||||
# --description--
|
||||
|
||||
JavaScript offers the built-in `Math` utility which offers a number of mathematical tools. One of those is `Math.random()`, which generates a random number between 0 and 1. Another is `Math.floor()`, which rounds a given number down to the nearest integer.
|
||||
JavaScript пропонує вбудовану утиліту `Math`, яка пропонує ряд математичних інструментів. Одним із них є `Math.random()`, який генерує випадкове число від 0 до 1. Іншим є `Math.floor()`, яке заокруглює задане число до найближчого цілого числа.
|
||||
|
||||
Using these, you can generate a random number within a range. For example, this generates a random number between 1 and 5: `Math.floor(Math.random() * 5) + 1;`.
|
||||
З їх використанням ви можете згенерувати випадкове число в межах діапазону. Наприклад, це генерує випадкове число від 1 до 5: `Math.floor(Math.random() * 5) + 1;`.
|
||||
|
||||
Following this pattern, add a random number between one and the value of `xp` at the end of your `monsterHealth` variable change.
|
||||
Використовуючи цей шаблон, додайте випадкове число між 1 та значенням `xp` в кінці своєї змінної `monsterHealth`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use the same `monsterHealth` line you already wrote.
|
||||
Ви повинні використати той рядок `monsterHealth`, який ви вже писали.
|
||||
|
||||
```js
|
||||
assert.lengthOf(attack.toString().match(/monsterHealth/g), 1);
|
||||
```
|
||||
|
||||
You should add to the `weapons[currentWeapon].power` value.
|
||||
Ви повинні додати до значення `weapons[currentWeapon].power`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /monsterHealth\s*-=\s*weapons\[currentWeapon\]\.power\s*\+/);
|
||||
@@ -45,19 +45,19 @@ assert.match(attack.toString(), /Math\.random/);
|
||||
assert.match(attack.toString(), /Math\.random\(\)\s*\*\s*xp/);
|
||||
```
|
||||
|
||||
You should use `Math.floor()` to round the result of `Math.random() * xp` down.
|
||||
Ви повинні використати `Math.floor()`, щоб заокруглити результат `Math.random() * xp`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /Math\.floor\(\s*Math\.random\(\)\s*\*\s*xp\s*\)/);
|
||||
```
|
||||
|
||||
You should add `1` to the result of `Math.floor()`.
|
||||
Ви повинні додати `1` до результату `Math.floor()`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /Math\.floor\(\s*Math\.random\(\)\s*\*\s*xp\s*\)\s*\+\s*1/);
|
||||
```
|
||||
|
||||
You should add the result of `Math.floor(Math.random() * xp) + 1` to the result of `weapons[currentWeapon].power`.
|
||||
Ви повинні додати результат `Math.floor(Math.random() * xp) + 1` до результату `weapons[currentWeapon].power`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /monsterHealth\s*-=\s*weapons\[currentWeapon\]\.power\s*\+\s*Math\.floor\(\s*Math\.random\(\)\s*\*\s*xp\s*\)\s*\+\s*1/);
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ dashedName: step-127
|
||||
assert.match(dodge.toString(), /text\.innerText\s*=\s*('|")You dodge the attack from the \1/);
|
||||
```
|
||||
|
||||
You should use the concatenation operator to add the name of the monster to the end of the string. You can get this with `monster[fighting].name`.
|
||||
Ви повинні використати оператор конкатенації, щоб додати назву монстра в кінець рядка. Її можна отримати за допомогою `monster[fighting].name`.
|
||||
|
||||
```js
|
||||
assert.match(dodge.toString(), /text\.innerText\s*=\s*('|")You dodge the attack from the \1\s*\+\s*monsters\[fighting\]\.name/);
|
||||
|
||||
+4
-4
@@ -7,9 +7,9 @@ dashedName: step-128
|
||||
|
||||
# --description--
|
||||
|
||||
In your `defeatMonster` function, set `gold` equal to `gold` plus the monster's level times `6.7`. You can get the monster's level with the `level` property.
|
||||
У своїй функції `defeatMonster` встановіть `gold` на `gold` плюс рівень монстра, помножений на `6.7`. Рівень монстра можна отримати за допомогою властивості `level`.
|
||||
|
||||
Here is an example of setting `num` to `num` plus `5` * `8`: `num += 5 * 8`. Use `Math.floor()` to round the result down.
|
||||
Ось приклад встановлення `num` на `num` плюс `5` * `8`: `num += 5 * 8`. Використайте `Math.floor()`, щоб заокруглити результат.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -19,13 +19,13 @@ Here is an example of setting `num` to `num` plus `5` * `8`: `num += 5 * 8`. Use
|
||||
assert.match(defeatMonster.toString(), /gold\s*\+=/);
|
||||
```
|
||||
|
||||
You should use `Math.floor()` to round the result of the monster's level times `6.7`.
|
||||
Ви повинні використати `Math.floor()`, щоб заокруглити результат множення рівня монстра на `6.7`.
|
||||
|
||||
```js
|
||||
assert.match(defeatMonster.toString(), /Math\.floor\(\s*monsters\[fighting\]\.level\s*\*\s*6\.7\s*\)/);
|
||||
```
|
||||
|
||||
You should add the result of `Math.floor(gold + monsters[fighting].level * 6.7)` to `gold`.
|
||||
Ви повинні додати результат `Math.floor(gold + monsters[fighting].level * 6.7)` до `gold`.
|
||||
|
||||
```js
|
||||
assert.match(defeatMonster.toString(), /gold\s*\+=\s*Math\.floor\(\s*monsters\[fighting\]\.level\s*\*\s*6\.7\s*\)/);
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ dashedName: step-134
|
||||
|
||||
# --description--
|
||||
|
||||
After a monster is defeated, the monster's stat box should no longer display. On the first line of the `update` function, use `monsterStats.style.display` to change the `display` value to `none`.
|
||||
Вікно статистики монстра більше не повинно відображатися після перемоги над монстром. У першому рядку функції `update` використайте `monsterStats.style.display`, щоб змінити значення `display` на `none`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -23,7 +23,7 @@ assert.match(update.toString(), /monsterStats\.style\.display/);
|
||||
assert.match(update.toString(), /monsterStats\.style\.display\s*=\s*('|")none\1/);
|
||||
```
|
||||
|
||||
You should add your code in the first line of the `update` function.
|
||||
Ви повинні додати свій код у перший рядок функції `update`.
|
||||
|
||||
```js
|
||||
assert.match(update.toString(), /update\s*\(\s*location\s*\)\s*\{\s*monsterStats\.style\.display\s*=\s*('|")none\1/);
|
||||
|
||||
+3
-3
@@ -7,9 +7,9 @@ dashedName: step-144
|
||||
|
||||
# --description--
|
||||
|
||||
The attack of the monster will be based on the monster's `level` and the player's `xp`. Використайте `const` у функції `getMonsterAttackValue`, щоб створити змінну під назвою `hit`. Assign it the equation `(level * 5) - (Math.floor(Math.random() * xp));`.
|
||||
Атака монстра базуватиметься на `level` (рівні) монстра та `xp` гравця. Використайте `const` у функції `getMonsterAttackValue`, щоб створити змінну під назвою `hit`. Призначте до неї рівняння `(level * 5) - (Math.floor(Math.random() * xp));`.
|
||||
|
||||
This will set the monster's attack to five times their `level` minus a random number between 0 and the player's `xp`.
|
||||
Це встановить атаку монстра на його `level`, помножений на 5, мінус випадкове число від 0 до `xp` гравця.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -19,7 +19,7 @@ This will set the monster's attack to five times their `level` minus a random nu
|
||||
assert.match(code, /const\s*hit/);
|
||||
```
|
||||
|
||||
You should use the equation `(level * 5) - (Math.floor(Math.random() * xp))`.
|
||||
Ви повинні використати рівняння `(level * 5) - (Math.floor(Math.random() * xp))`.
|
||||
|
||||
```js
|
||||
assert.match(getMonsterAttackValue, /(level\s*\*\s*5)\s*-\s*(Math.floor\(Math.random\(\)\s*\*\s*xp\))/);
|
||||
|
||||
+2
-2
@@ -7,11 +7,11 @@ dashedName: step-145
|
||||
|
||||
# --description--
|
||||
|
||||
Log the value of `hit` to the console to use in debugging. Remember that you can do this with `console.log()`.
|
||||
Зареєструйте значення `hit` у консолі, щоб використати його під час налагодження. Це можна зробити за допомогою `console.log()`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use the `console.log()` function to log the value of `hit`.
|
||||
Ви повинні використати функцію `console.log()`, щоб зареєструвати значення `hit`.
|
||||
|
||||
```js
|
||||
assert.match(getMonsterAttackValue.toString(), /console\.log\(\s*hit\s*\)/);
|
||||
|
||||
+6
-6
@@ -7,27 +7,27 @@ dashedName: step-152
|
||||
|
||||
# --description--
|
||||
|
||||
The player should hit if either `Math.random() > .2` **or** if the player's health is less than 20. At the end of your `return` statement, use the <dfn>logical or</dfn> operator `||` and check if `health` is less than `20`.
|
||||
Гравець може завдати удару, якщо `Math.random() > .2` **або** його здоров'я менше за 20. В кінці своєї інструкції `return` використайте <dfn>логічний оператор or</dfn> `||`, щоб перевірити, чи `health` менше за `20`.
|
||||
|
||||
The logical or operator will use the first value if it is truthy, otherwise it will use the second value.
|
||||
Логічний оператор or використовуватиме перше значення, якщо воно істинне; в іншому випадку він використовуватиме друге значення.
|
||||
|
||||
For example: `num < 10 || num > 20`.
|
||||
Наприклад: `num < 10 || num > 20`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `isMonsterHit` function should use the logical or operator.
|
||||
Ваша функція `isMonsterHit` повинна використовувати логічний оператор or.
|
||||
|
||||
```js
|
||||
assert.match(isMonsterHit.toString(), /\|\|/);
|
||||
```
|
||||
|
||||
Your logical or operator should use `health < 20` as the fallback value.
|
||||
Ваш логічний оператор or повинен використовувати `health < 20` як резервне значення.
|
||||
|
||||
```js
|
||||
assert.match(isMonsterHit.toString(), /\|\|\s*health\s*<\s*20/);
|
||||
```
|
||||
|
||||
Your function should return the result of the comparison `Math.random() > .2` **or** `health < 20`.
|
||||
Ваша функція повинна повернути результат порівняння `Math.random() > .2` **або** `health < 20`.
|
||||
|
||||
```js
|
||||
assert.match(isMonsterHit.toString(), /return\s*Math\.random\(\)\s*>\s*0?\.2\s*\|\|\s*health\s*<\s*20/);
|
||||
|
||||
+4
-4
@@ -7,7 +7,7 @@ dashedName: step-154
|
||||
|
||||
# --description--
|
||||
|
||||
Use the `+=` operator to add `Your [weapon] breaks.`, with a space in front of `Your`, to the end of `text.innerText`. Replace `[weapon]` with the last item in the `inventory` array using `inventory.pop()`, which will remove the last item in the array AND return it so it appears in your string.
|
||||
Використайте оператор `+=`, щоб додати `Your [weapon] breaks.`, з пробілом перед `Your`, у кінець `text.innerText`. Замініть `[weapon]` на останній елемент у масиві `inventory`, використовуючи `inventory.pop()`, який видалить останній предмет у масиві ТА поверніть його так, щоб він з’явився у вашому рядку.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -24,20 +24,20 @@ assert.lengthOf(concat, 3);
|
||||
assert.match(attack.toString(), /inventory\.pop\(\)/);
|
||||
```
|
||||
|
||||
You should add `Your`, with a space before and after it, to `text.innerText`.
|
||||
Ви повинні додати `Your` (з пробілом перед і після) до `text.innerText`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1/);
|
||||
```
|
||||
|
||||
You should add the return value of `inventory.pop()` to the `Your` string.
|
||||
Ви повинні додати значення, що повертається `inventory.pop()` до рядка `Your`.
|
||||
|
||||
```js
|
||||
console.log(attack.toString());
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)/);
|
||||
```
|
||||
|
||||
You should add `breaks.`, with a space in front of it, to the end of your string.
|
||||
Ви повинні додати `breaks.` (з пробілом перед) у кінець рядка.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /text\.innerText\s*\+=\s*('|")\sYour\s\1\s*\+\s*inventory\.pop\(\)\s*\+\s*('|")\sbreaks\.\2/);
|
||||
|
||||
+4
-4
@@ -7,19 +7,19 @@ dashedName: step-155
|
||||
|
||||
# --description--
|
||||
|
||||
Remember that the increment operator `++` can be used to increase a variable's value by 1. There is also a <dfn>decrement operator</dfn> `--` that can be used to decrease a variable's value by 1.
|
||||
Пам'ятайте, що оператор інкременту `++` можна використати, щоб збільшити значення змінної на 1. Також існує <dfn>оператор декременту</dfn> `--` для того, щоб зменшити значення змінної на 1.
|
||||
|
||||
Decrement the value of `currentWeapon` in your `if` statement, after you update the text.
|
||||
Після того, як ви оновите текст, зменште значення `currentWeapon` у своїй інструкції `if`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use the decrement operator.
|
||||
Ви повинні використати оператор декременту.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /--/);
|
||||
```
|
||||
|
||||
You should decrement `currentWeapon` in your `if` statement.
|
||||
Ви повинні зменшити `currentWeapon` у своїй інструкції `if`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /currentWeapon\s*--/);
|
||||
|
||||
+5
-5
@@ -7,11 +7,11 @@ dashedName: step-156
|
||||
|
||||
# --description--
|
||||
|
||||
We don't want a player's only weapon to break. The logical AND operator checks if two statements are true.
|
||||
Ми не хочемо, щоб єдина зброя гравця зламалася. Логічний оператор AND перевіряє, чи обидві інструкції істинні.
|
||||
|
||||
Use the <dfn>logical AND</dfn> operator `&&` to add a second condition to your `if` statement. The player's weapon should only break if `inventory.length` does not equal (`!==`) one.
|
||||
Використайте <dfn>логічний оператор AND</dfn> `&&`, щоб додати другу умову до своєї інструкції `if`. Зброя гравця буде зламана лише за умови, що `inventory.length` не дорівнює (`!==`) одиниці.
|
||||
|
||||
Here is an example of an `if` statement with two conditions:
|
||||
Ось приклад інструкції `if` з двома умовами:
|
||||
|
||||
```js
|
||||
if (firstName === "Quincy" && lastName === "Larson") {
|
||||
@@ -27,13 +27,13 @@ if (firstName === "Quincy" && lastName === "Larson") {
|
||||
assert.match(attack.toString(), /if\s*\(Math\.random\(\)\s*\<=\s*\.1/);
|
||||
```
|
||||
|
||||
You should use the logical AND operator `&&`.
|
||||
Ви повинні використати логічний оператор AND `&&`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /if\s*\(Math\.random\(\)\s*\<=\s*\.1\s*&&/);
|
||||
```
|
||||
|
||||
You should use the logical AND operator to check if `inventory.length` does not equal `1`.
|
||||
Ви повинні використати логічний оператор AND, щоб перевірити, чи `inventory.length` не дорівнює `1`.
|
||||
|
||||
```js
|
||||
assert.match(attack.toString(), /if\s*\(Math\.random\(\)\s*\<=\s*\.1\s*&&\s*inventory\.length\s*\!\=\=\s*1\s*\)/);
|
||||
|
||||
+2
-2
@@ -17,13 +17,13 @@ dashedName: step-164
|
||||
assert.match(pick.toString(), /text\.innerText\s*=\s*('|")You picked \1/);
|
||||
```
|
||||
|
||||
You should use the concatenation operator to add the value of the `guess` parameter to your `You picked` string.
|
||||
Ви повинні використати оператор конкатенації, щоб додати значення параметра `guess` до свого рядка `You picked`.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /text\.innerText\s*=\s*('|")You picked \1\s*\+\s*guess/);
|
||||
```
|
||||
|
||||
You should use the concatenation operator to add the string `. Here are the random numbers:` to your `"You picked " + guess` string.
|
||||
Ви повинні використати оператор конкатенації, щоб додати рядок `. Here are the random numbers:` до свого рядка `"You picked " + guess`.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /text\.innerText\s*=\s*('|")You picked \1\s*\+\s*guess\s*\+\s*('|")\.\sHere are the random numbers:\2/);
|
||||
|
||||
+2
-2
@@ -7,11 +7,11 @@ dashedName: step-165
|
||||
|
||||
# --description--
|
||||
|
||||
Before the final quote in that string you added, insert the new line escape character `\n`. This will cause the next part you add to `text.innerText` to appear on a new line.
|
||||
Перед останньою лапкою в цьому рядку, який ви додали, вставте екранований символ нового рядка `\n`. Це призведе до того, що наступна частина, яку ви додасте до `text.innerText`, з’явиться в новому рядку.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should add the new line escape character `\n` to your `. Here are the random numbers:` string.
|
||||
Ви повинні додати символ екранування нового рядка `\n` до свого рядка `. Here are the random numbers:`.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /text\.innerText\s*=\s*('|")You picked \1\s*\+\s*guess\s*\+\s*('|")\.\sHere are the random numbers:\\n\2/);
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ dashedName: step-166
|
||||
|
||||
# --description--
|
||||
|
||||
A `for` loop runs for a specific number of times. We will break down how a `for` loop runs in the next several steps. For now, copy this loop below and paste it at the end of your `pick` function.
|
||||
Цикл `for` виконується певну кількість разів. У наступних кроках ми розберемо, як виконується цикл `for`. А поки скопіюйте та вставте нижчеподаний цикл у кінець функції `pick`.
|
||||
|
||||
```js
|
||||
for (let x = 1; x < 5; x++) {
|
||||
@@ -17,7 +17,7 @@ for (let x = 1; x < 5; x++) {
|
||||
|
||||
# --hints--
|
||||
|
||||
You should copy the above loop into your `pick` function.
|
||||
Ви повинні скопіювати вищеподаний цикл до функції `pick`.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /for\s*\(\s*(let|var)\s*x\s*=\s*1\s*;\s*x\s*<\s*5\s*;\s*x\s*\+\+\s*\)/);
|
||||
|
||||
+4
-4
@@ -7,15 +7,15 @@ dashedName: step-167
|
||||
|
||||
# --description--
|
||||
|
||||
`for` loops are declared with three expressions separated by semicolons. `for (a; b; c)`, where `a` is the initialization expression, `b` is the condition, and `c` is the final expression.
|
||||
Цикли `for` оголошуються трьома виразами, які розділені крапкою з комою. `for (a; b; c)`, де `a` – вираз ініціалізації, `b` – умова, `c` – кінцевий вираз.
|
||||
|
||||
The initialization expression is executed only once, before the loop starts, and is often used to define and set up the loop variable. Think of it like declaring a counter to use in your loop.
|
||||
Вираз ініціалізації виконується лише раз, перед початком циклу, та часто використовується для визначення та налаштування змінної циклу. Сприймайте це як оголошення лічильника, щоб використати його у своєму циклі.
|
||||
|
||||
Many `for` loops use `i` as the counter and start from 0, so change `let x = 1;` to `let i = 0;`.
|
||||
Багато циклів `for` використовують `i` як лічильник та починають з 0, тому змініть `let x = 1;` на `let i = 0;`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should change your initialization in the `for` loop to be `let i = 0;`.
|
||||
Ви повинні змінити ініціалізацію у циклі `for` на `let i = 0;`.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /for\s*\(\s*(let|var)\s*i\s*=\s*0\s*;/)
|
||||
|
||||
+2
-2
@@ -7,13 +7,13 @@ dashedName: step-168
|
||||
|
||||
# --description--
|
||||
|
||||
The second statement in a `for` loop, the condition statement, is evaluated at the beginning of every loop iteration. The loop will continue as long as the condition evaluates to be true.
|
||||
Друга інструкція у циклі `for`, умовна інструкція, обчислюється на початку кожної ітерації циклу. Цикл продовжується, поки умова істинна.
|
||||
|
||||
Цикл повинен виконуватись 10 раз, тому змініть `x < 5` на `i < 10`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should update your condition statement to be `i < 10`.
|
||||
Ви повинні оновити свою умовну інструкцію на `i < 10`.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /for\s*\(\s*(let|var)\s*i\s*=\s*0\s*;\s*i\s*<\s*10\s*;/)
|
||||
|
||||
+2
-2
@@ -7,9 +7,9 @@ dashedName: step-169
|
||||
|
||||
# --description--
|
||||
|
||||
The last statement in a `for` loop, the final expression, is executed at the end of each loop iteration.
|
||||
Остання інструкція у циклі `for`, кінцевий вираз, виконується вкінці кожної ітерації циклу.
|
||||
|
||||
Since we changed the initialization statement to use `i` instead of `x`, change `x++` to `i++`. This will increment the initializer `i` by 1 after each loop.
|
||||
Оскільки тепер інструкція ініціалізації використовує `i` замість `x`, змініть `x++` на `i++`. Це збільшить ініціалізатор `i` на 1 після кожного циклу.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
+2
-2
@@ -7,7 +7,7 @@ dashedName: step-170
|
||||
|
||||
# --description--
|
||||
|
||||
Now you can write the logic to run in the loop. Inside your `for` loop, use the `+=` operator to add to the end of `text.innerText`. Add the number at index `i` of the `numbers` array, using `numbers[i]`. Then add a new line, using the escape sequence you used earlier.
|
||||
Тепер ви можете написати логіку для запуску в циклі. Усередині циклу `for` скористайтеся оператором `+=`, щоб додати у кінець `text.innerText`. Додайте число в індексі `i` масиву `numbers`, використовуючи `numbers[i]`. Потім додайте новий рядок, використовуючи керуючу послідовність, яку ви використовували раніше.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -29,7 +29,7 @@ assert.match(pick.toString(), /numbers\[i\]/);
|
||||
assert.match(pick.toString(), /text\.innerText\s*\+=\s*numbers\[i\]/);
|
||||
```
|
||||
|
||||
You should add a new-line character after the `numbers[i]` value. Remember that you can do this with `\n`.
|
||||
Ви повинні додати символ нового рядка після значення `numbers[i]`. Це можна зробити за допомогою `\n`.
|
||||
|
||||
```js
|
||||
console.log(pick.toString());
|
||||
|
||||
+4
-4
@@ -7,11 +7,11 @@ dashedName: step-171
|
||||
|
||||
# --description--
|
||||
|
||||
The `indexOf()` array method returns the first index at which a given element can be found in the array, or `-1` if the element is not present.
|
||||
Метод масиву `indexOf()` повертає перший індекс, за яким можна знайти заданий елемент у масиві, або `-1`, якщо елемент відсутній.
|
||||
|
||||
After your `for` loop, add an `if` expression to check if the `guess` is in the `numbers` array. You can check if `indexOf` is not equal (`!==`) to `-1`.
|
||||
Додайте вираз `if` після циклу `for`, щоб перевірити, чи `guess` знаходиться в масиві `numbers`. Ви можете перевірити, чи `indexOf` не дорівнює (`!==`) `-1`.
|
||||
|
||||
Here is an example of the `indexOf` syntax:
|
||||
Ось приклад синтаксису `indexOf`:
|
||||
|
||||
```js
|
||||
const numbers = [1, 2, 3];
|
||||
@@ -26,7 +26,7 @@ numbers.indexOf(2) // 1
|
||||
assert.match(pick.toString(), /if/);
|
||||
```
|
||||
|
||||
Your `if` statement should check if the `guess` is in the `numbers` array. You can check if `indexOf` is not equal (`!==`) to `-1`.
|
||||
Ваша інструкція `if` повинна перевіряти, чи `guess` знаходиться в масиві `numbers`. Ви можете перевірити, чи `indexOf` не дорівнює (`!==`) `-1`.
|
||||
|
||||
```js
|
||||
assert.match(pick.toString(), /if\s*\(numbers\.indexOf\(\s*guess\s*\)\s*!==\s*-1\s*\)/);
|
||||
|
||||
+3
-3
@@ -7,13 +7,13 @@ dashedName: step-175
|
||||
|
||||
# --description--
|
||||
|
||||
Looking at your `kill monster` object, `button functions` currently has three `goTown` variables. Replace the third one with `easterEgg` - this is how a player will access the hidden feature of the game. Не змінюйте `button text`.
|
||||
Глянувши на ваш об'єкт `kill monster`, `button functions` зараз має три змінні `goTown`. Змініть третю на `easterEgg`: таким чином гравець отримає доступ до прихованої властивості гри. Не змінюйте `button text`.
|
||||
|
||||
На цьому ваша рольова гра готова! You can now play around - can you defeat the dragon?
|
||||
На цьому ваша рольова гра готова! Ви можете зіграти в неї, але чи можете ви побороти дракона?
|
||||
|
||||
# --hints--
|
||||
|
||||
You should update your fifth `locations` object to have a `button functions` property of `[goTown, goTown, easterEgg]`.
|
||||
Ви повинні оновити свій п'ятий об'єкт `locations`, щоб він мав властивість `button functions` зі значенням `[goTown, goTown, easterEgg]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[4]["button functions"], [goTown, goTown, easterEgg]);
|
||||
|
||||
+4
-4
@@ -7,20 +7,20 @@ dashedName: step-30
|
||||
|
||||
# --description--
|
||||
|
||||
We have run in to a slight problem. You are trying to query your page for a button element, but your `script` tag is in the `head` of your HTML. This means your code runs before the browser has finished reading the HTML, and your `document.querySelector()` will not see the button - because the browser hasn't processed it yet.
|
||||
Ми зіткнулися з невеликою проблемою. Ви намагаєтеся запитати на своїй сторінці елемент кнопки, але ваш теґ `script` знаходиться в `head` вашого HTML. Це означає, що ваш код запускається до того, як браузер завершить читання HTML, та ваш `document.querySelector()` не побачить кнопку, оскільки браузер ще не обробив її.
|
||||
|
||||
To fix this, move your `script` element out of the `head` element, and place it at the end of your `body` element (just before the closing `</body>` tag.)
|
||||
Щоб виправити це, перемістіть елемент `script` з елемента `head` та розмістіть його в кінці свого елемента `body` (відразу перед кінцевим теґом `</body>`).
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `script` element should not be in your `head` element.
|
||||
Ваш елемент `script` не повинен бути в елементі `head`.
|
||||
|
||||
```js
|
||||
const script = document.querySelector('script[data-src$="script.js"]');
|
||||
assert.notEqual(script.parentElement.tagName, "HEAD");
|
||||
```
|
||||
|
||||
Your `script` element should come at the end of your `body` element.
|
||||
Ваш елемент `script` повинен бути в кінці елемента `body`.
|
||||
|
||||
```js
|
||||
const script = document.querySelector('script[data-src$="script.js"]');
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ dashedName: step-137
|
||||
|
||||
# --description--
|
||||
|
||||
У масив `locations` додайте ще один об’єкт у кінці. Set the `name` property to `lose`, set `button text` to an array with three `REPLAY?` strings, set `button functions` to an array with three `restart` variables, and set `text` to `You die. ☠️`. You can copy that text to use the emote.
|
||||
У масив `locations` додайте ще один об’єкт у кінці. Встановіть властивість `name` на `lose`, встановіть `button text` на масив з трьома рядками `REPLAY?`, встановіть `button functions` на масив з трьома змінними `restart` та встановіть `text` на `You die. ☠️`. Ви можете скопіювати цей текст, щоб використати емот.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -29,13 +29,13 @@ assert.isObject(locations[5]);
|
||||
assert.equal(locations[5].name, 'lose');
|
||||
```
|
||||
|
||||
Your sixth `locations` value should have a `button text` array with three `REPLAY?` strings.
|
||||
Ваше шосте значення `locations` повинне мати масив `button text` з трьома рядками `REPLAY?`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[5]["button text"], ['REPLAY?', 'REPLAY?', 'REPLAY?']);
|
||||
```
|
||||
|
||||
Your sixth `locations` value should have a `button functions` array with three `restart` variables.
|
||||
Ваше шосте значення `locations` повинне мати масив `button functions` з трьома змінними `restart`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(locations[5]["button functions"], [restart, restart, restart]);
|
||||
|
||||
Reference in New Issue
Block a user