mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-20 12:03:11 -04:00
chore(i18n,learn): processed translations (#49013)
This commit is contained in:
@@ -9,7 +9,7 @@ dashedName: assigning-the-value-of-one-variable-to-another
|
||||
|
||||
# --description--
|
||||
|
||||
بعد تعيين قيمة إلى متغير باستخدام عملية <dfn>تكليف (=)</dfn>، يمكنك تعيين قيمة هذا المتغير إلى متغير آخر باستخدام عملية <dfn>تكليف (=)</dfn> ذاتها.
|
||||
بعد تعيين قيمة إلى متغير باستخدام مشغل <dfn>التعيين (=)</dfn>، يمكنك تعيين قيمة هذا المتغير إلى متغير آخر باستخدام مشغل <dfn>التعيين (=)</dfn> ذاتها.
|
||||
|
||||
```js
|
||||
var myVar;
|
||||
|
||||
@@ -9,7 +9,7 @@ dashedName: global-scope-and-functions
|
||||
|
||||
# --description--
|
||||
|
||||
في JavaScript، يشير <dfn>النطاق</dfn> إلى رؤية المتغيرات. يكون إلى المتغيرات التي تم تعريفها خارج الوظيفة نطاق يسمي <dfn>شامل</dfn>. وهذا يعني أنه يمكن رؤيتها في كل مكان في التعليمات البرمجية JavaScript الخاص بك.
|
||||
في JavaScript، يشير <dfn>النطاق</dfn> إلى رؤية المتغيرات. يكون إلى المتغيرات التي تم تعريفها خارج الوظيفة مجال <dfn>شامل</dfn> (Global scope). وهذا يعني أنه يمكن رؤيتها في كل مكان في التعليمات البرمجية JavaScript الخاص بك.
|
||||
|
||||
تعلن المتغيرات دون استخدام المصطلحات الآتية `let` أو `const` وتنشئ تلقائيًا في نطاق `global`. هذا يمكن أن يؤدي إلى عواقب غير مقصودة في مكان آخر من التعليمات البرمجية الخاص بك أو عند تشغيل الوظيفة مرة أخرى. يجب عليك دائماً إعلان متغيراتك باستخدام `let` أو `const`.
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ var myVar = 0;
|
||||
|
||||
# --instructions--
|
||||
|
||||
أعلن متغير `a` باستخدام `var` و عيّن له قيمة `9`.
|
||||
أعلن متغير `a` باستخدام `var` و هيئ له قيمة `9`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ myFun();
|
||||
عدّل الوظيفة `abTest` بحيث إذا كان `a` أو `b` أقل من `0` ستنتج الوظيفة قيمة `undefined` فوراً.
|
||||
|
||||
**تلميح**
|
||||
تذكر أن <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> كلمة</a> وليست مقتطع.
|
||||
تذكر أن <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> مصطلح </a> وليست مقطع نصي.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ function addSum(num) {
|
||||
addSum(3);
|
||||
```
|
||||
|
||||
تكون `addSum` وظيفة دون `return`. سيغير وظيفة المتغير `sum` العالمي الآتي, ولكن تكون القيمة المرتجعة للوظيفة `undefined`.
|
||||
تكون `addSum` وظيفة دون `return`. ستغير الوظيفة المتغير الشامل `sum`، ولكن تكون القيمة المرتجعة للوظيفة `undefined`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
|
||||
@@ -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> إي "ليس رقما". إذا ربط مقطع نصي مع متغير `undefined`، فستحصل على <dfn>مقطع نصي</dfn> بقيمة `undefined`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ dashedName: serve-an-html-file
|
||||
|
||||
# --description--
|
||||
|
||||
You can respond to requests with a file using the `res.sendFile(path)` method. You can put it inside the `app.get('/', ...)` route handler. Behind the scenes, this method will set the appropriate headers to instruct your browser on how to handle the file you want to send, according to its type. Then it will read and send the file. This method needs an absolute file path. We recommend you to use the Node global variable `__dirname` to calculate the path like this:
|
||||
You can respond to requests with a file using the `res.sendFile(path)` method. You can put it inside the `app.get('/', ...)` route handler. خلف الكواليس، ستضبط تلك الطريقة العناوين المناسبة لترشد متصفحك عن كيفية التعامل مع الملف الذي تريد إرساله، وفقًا لنوعه. Then it will read and send the file. This method needs an absolute file path. We recommend you to use the Node global variable `__dirname` to calculate the path like this:
|
||||
|
||||
```js
|
||||
absolutePath = __dirname + relativePath/file.ext
|
||||
|
||||
@@ -16,7 +16,7 @@ dashedName: data-cleaning-with-dataframes
|
||||
|
||||
More resources:
|
||||
|
||||
- <a href="https://github.com/ine-rmotr-curriculum/data-cleaning-rmotr-freecodecamp" target="_blank" rel="noopener noreferrer nofollow">Notebooks on GitHub</a>
|
||||
- <a href="https://github.com/ine-rmotr-curriculum/data-cleaning-rmotr-freecodecamp" target="_blank" rel="noopener noreferrer nofollow">Notebooks على GitHub</a>
|
||||
- <a href="https://colab.research.google.com/github/googlecolab/colabtools/blob/master/notebooks/colab-github-demo.ipynb" target="_blank" rel="noopener noreferrer nofollow">كيفية فتح Notebooks من GitHub باستخدام Google Colab.</a>
|
||||
|
||||
# --question--
|
||||
|
||||
@@ -30,7 +30,7 @@ assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.prev
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.localName === 'span');
|
||||
```
|
||||
|
||||
Your first `span` element not be bold.
|
||||
Your first `span` element should not be bold.
|
||||
|
||||
```js
|
||||
assert(!document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.classList?.contains('bold'));
|
||||
|
||||
@@ -30,7 +30,7 @@ assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.prev
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.localName === 'span');
|
||||
```
|
||||
|
||||
Your first `span` element not be bold.
|
||||
Your first `span` element should not be bold.
|
||||
|
||||
```js
|
||||
assert(!document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.classList?.contains('bold'));
|
||||
|
||||
@@ -30,7 +30,7 @@ assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.prev
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.localName === 'span');
|
||||
```
|
||||
|
||||
Your first `span` element not be bold.
|
||||
Your first `span` element should not be bold.
|
||||
|
||||
```js
|
||||
assert(!document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.classList?.contains('bold'));
|
||||
|
||||
@@ -30,7 +30,7 @@ Su primer elemento nuevo `p` debe tener un elemento `span`.
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.localName === 'span');
|
||||
```
|
||||
|
||||
Your first `span` element not be bold.
|
||||
Your first `span` element should not be bold.
|
||||
|
||||
```js
|
||||
assert(!document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.classList?.contains('bold'));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3db1000cf542c50feed
|
||||
title: 'Problem 110: Diophantine Reciprocals II'
|
||||
title: 'Problem 110: Diophantische Umkehrfunktionen II'
|
||||
challengeType: 1
|
||||
forumTopicId: 301735
|
||||
dashedName: problem-110-diophantine-reciprocals-ii
|
||||
@@ -8,19 +8,19 @@ dashedName: problem-110-diophantine-reciprocals-ii
|
||||
|
||||
# --description--
|
||||
|
||||
In the following equation x, y, and n are positive integers.
|
||||
In der folgenden Gleichung sind x, y und n positive ganze Zahlen.
|
||||
|
||||
$$\frac{1}{x} + \frac{1}{y} = \frac{1}{n}$$
|
||||
|
||||
It can be verified that when `n` = 1260 there are 113 distinct solutions and this is the least value of `n` for which the total number of distinct solutions exceeds one hundred.
|
||||
|
||||
What is the least value of `n` for which the number of distinct solutions exceeds four million?
|
||||
Was ist der geringste Wert von `n`, für den die Anzahl an unterschiedlichen Lösungen mehr als vier Millionen beträgt?
|
||||
|
||||
**Note:** This problem is a much more difficult version of Problem 108 and as it is well beyond the limitations of a brute force approach it requires a clever implementation.
|
||||
**Hinweis:** Dieses Problem ist eine viel schwierigere Version des Problems 108 und, da es weit über die Grenzen der Brute-Force-Methode hinausgeht, benötigt es eine geschickte Umsetzung.
|
||||
|
||||
# --hints--
|
||||
|
||||
`diophantineTwo()` should return `9350130049860600`.
|
||||
`diophantineTwo()` sollte `9350130049860600` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(diophantineTwo(), 9350130049860600);
|
||||
|
||||
@@ -8,34 +8,34 @@ dashedName: problem-111-primes-with-runs
|
||||
|
||||
# --description--
|
||||
|
||||
Considering 4-digit primes containing repeated digits it is clear that they cannot all be the same: 1111 is divisible by 11, 2222 is divisible by 22, and so on. But there are nine 4-digit primes containing three ones:
|
||||
Bei 4-stelligen Primzahlen mit wiederholten Ziffern ist klar, dass sie nicht alle gleich sein können: 1111 ist durch 11 teilbar, 2222 ist durch 22 teilbar, usw. Aber es gibt neun 4-stellige Primzahlen, die drei Einsen enthalten:
|
||||
|
||||
$$1117, 1151, 1171, 1181, 1511, 1811, 2111, 4111, 8111$$
|
||||
|
||||
We shall say that $M(n, d)$ represents the maximum number of repeated digits for an n-digit prime where d is the repeated digit, $N(n, d)$ represents the number of such primes, and $S(n, d)$ represents the sum of these primes.
|
||||
Wir sagen, dass $M(n, d)$ die maximale Anzahl wiederholter Ziffern für eine n-stellige Primzahl darstellt, wobei d die wiederholte Ziffer ist, $N(n, d)$ die Anzahl solcher Primzahlen, und $S(n, d)$ die Summe dieser Primzahlen.
|
||||
|
||||
So $M(4, 1) = 3$ is the maximum number of repeated digits for a 4-digit prime where one is the repeated digit, there are $N(4, 1) = 9$ such primes, and the sum of these primes is $S(4, 1) = 22275$. It turns out that for d = 0, it is only possible to have $M(4, 0) = 2$ repeated digits, but there are $N(4, 0) = 13$ such cases.
|
||||
Also ist $M(4, 1) = 3$ die maximale Anzahl der wiederholten Ziffern für eine vierstellige Primzahl, wobei eine die wiederholte Ziffer ist, es gibt $N(4, 1) = 9$ solcher Primzahlen, und die Summe dieser Primzahlen ist $S(4, 1) = 22275$. Es stellt sich heraus, dass es für d = 0 nur $M(4, 0) = 2$ wiederholte Ziffern geben kann, aber es gibt $N(4, 0) = 13$ solcher Fälle.
|
||||
|
||||
In the same way we obtain the following results for 4-digit primes.
|
||||
Auf die gleiche Weise erhalten wir die folgenden Ergebnisse für 4-stellige Primzahlen.
|
||||
|
||||
| Digit, d | $M(4, d)$ | $N(4, d)$ | $S(4, d)$ |
|
||||
| -------- | --------- | --------- | --------- |
|
||||
| 0 | 2 | 13 | 67061 |
|
||||
| 1 | 3 | 9 | 22275 |
|
||||
| 2 | 3 | 1 | 2221 |
|
||||
| 3 | 3 | 12 | 46214 |
|
||||
| 4 | 3 | 2 | 8888 |
|
||||
| 5 | 3 | 1 | 5557 |
|
||||
| 6 | 3 | 1 | 6661 |
|
||||
| 7 | 3 | 9 | 57863 |
|
||||
| 8 | 3 | 1 | 8887 |
|
||||
| 9 | 3 | 7 | 48073 |
|
||||
| Ziffer, d | $M(4, d)$ | $N(4, d)$ | $S(4, d)$ |
|
||||
| --------- | --------- | --------- | --------- |
|
||||
| 0 | 2 | 13 | 67061 |
|
||||
| 1 | 3 | 9 | 22275 |
|
||||
| 2 | 3 | 1 | 2221 |
|
||||
| 3 | 3 | 12 | 46214 |
|
||||
| 4 | 3 | 2 | 8888 |
|
||||
| 5 | 3 | 1 | 5557 |
|
||||
| 6 | 3 | 1 | 6661 |
|
||||
| 7 | 3 | 9 | 57863 |
|
||||
| 8 | 3 | 1 | 8887 |
|
||||
| 9 | 3 | 7 | 48073 |
|
||||
|
||||
For d = 0 to 9, the sum of all $S(4, d)$ is 273700. Find the sum of all $S(10, d)$.
|
||||
Für d = 0 bis 9 ist die Summe aller $S(4, d)$ 273700. Finde die Summe aller $S(10, d)$.
|
||||
|
||||
# --hints--
|
||||
|
||||
`primesWithRuns()` should return `612407567715`.
|
||||
`primesWithRuns()` sollte `612407567715` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(primesWithRuns(), 612407567715);
|
||||
|
||||
@@ -8,9 +8,9 @@ dashedName: problem-112-bouncy-numbers
|
||||
|
||||
# --description--
|
||||
|
||||
Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468.
|
||||
Wenn man von links nach rechts arbeitet und keine Ziffer durch die Ziffer links davon übertroffen wird, spricht man von einer aufsteigenden Zahl, zum Beispiel 134468.
|
||||
|
||||
Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420.
|
||||
Ähnlich verhält es sich, wenn keine Ziffer von der Ziffer rechts überschritten wird, wird es eine abnehmende Zahl genannt; zum Beispiel, 66420.
|
||||
|
||||
We shall call a positive integer that is neither increasing nor decreasing a "bouncy" number; for example, 155349.
|
||||
|
||||
|
||||
@@ -8,19 +8,19 @@ dashedName: problem-113-non-bouncy-numbers
|
||||
|
||||
# --description--
|
||||
|
||||
Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468.
|
||||
Wenn man von links nach rechts arbeitet und keine Ziffer durch die Ziffer links davon übertroffen wird, spricht man von einer aufsteigenden Zahl, zum Beispiel 134468.
|
||||
|
||||
Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420.
|
||||
Ähnlich verhält es sich, wenn keine Ziffer von der Ziffer rechts daneben übertroffen wird. Man spricht dann von einer absteigenden Zahl, zum Beispiel 66420.
|
||||
|
||||
We shall call a positive integer that is neither increasing nor decreasing a "bouncy" number; for example, 155349.
|
||||
|
||||
As n increases, the proportion of bouncy numbers below n increases such that there are only 12951 numbers below one-million that are not bouncy and only 277032 non-bouncy numbers below ${10}^{10}$.
|
||||
|
||||
How many numbers below a googol (${10}^{100}$) are not bouncy?
|
||||
Wie viele Zahlen unterhalb eines Googols (${10}^{100}$) sind nicht sprunghaft?
|
||||
|
||||
# --hints--
|
||||
|
||||
`nonBouncyNumbers()` should return `51161058134250`.
|
||||
`nonBouncyNumbers()` sollte `51161058134250` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(nonBouncyNumbers(), 51161058134250);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3e01000cf542c50fef2
|
||||
title: 'Problem 114: Counting block combinations I'
|
||||
title: 'Problem 114: Zählen von Blockkombinationen I'
|
||||
challengeType: 1
|
||||
forumTopicId: 301740
|
||||
dashedName: problem-114-counting-block-combinations-i
|
||||
@@ -8,17 +8,17 @@ dashedName: problem-114-counting-block-combinations-i
|
||||
|
||||
# --description--
|
||||
|
||||
A row measuring seven units in length has red blocks with a minimum length of three units placed on it, such that any two red blocks (which are allowed to be different lengths) are separated by at least one black square. There are exactly seventeen ways of doing this.
|
||||
Auf einer sieben Einheiten langen Reihe werden rote Blöcke mit einer Mindestlänge von drei Einheiten so platziert, dass zwei beliebige rote Blöcke (die unterschiedlich lang sein dürfen) durch mindestens ein schwarzes Quadrat getrennt sind. Es gibt genau siebzehn Möglichkeiten, dies zu tun.
|
||||
|
||||
<img class="img-responsive center-block" alt="Possible ways of placing block with a minimum length of three units, on a row with length of seven units" src="https://cdn.freecodecamp.org/curriculum/project-euler/counting-block-combinations-i.png" style="background-color: white; padding: 10px;" />
|
||||
<img class="img-responsive center-block" alt="Möglichkeiten der Platzierung von Blöcken mit einer Mindestlänge von drei Einheiten in einer Reihe mit einer Länge von sieben Einheiten" src="https://cdn.freecodecamp.org/curriculum/project-euler/counting-block-combinations-i.png" style="background-color: white; padding: 10px;" />
|
||||
|
||||
How many ways can a row measuring fifty units in length be filled?
|
||||
Auf wie viele Arten kann eine Reihe mit einer Länge von fünfzig Einheiten gefüllt werden?
|
||||
|
||||
**Note:** Although the example above does not lend itself to the possibility, in general it is permitted to mix block sizes. For example, on a row measuring eight units in length you could use red (3), black (1), and red (4).
|
||||
**Hinweis:** Obwohl das obige Beispiel keine Möglichkeit bietet, ist es im Allgemeinen erlaubt, Blockgrößen zu mischen. Bei einer Reihe mit einer Länge von acht Einheiten kannst du zum Beispiel rot (3), schwarz (1) und rot (4) verwenden.
|
||||
|
||||
# --hints--
|
||||
|
||||
`countingBlockOne()` should return `16475640049`.
|
||||
`countingBlockOne()` sollte `16475640049` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(countingBlockOne(), 16475640049);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3df1000cf542c50fef1
|
||||
title: 'Problem 115: Counting block combinations II'
|
||||
title: 'Problem 115: Zählen von Blockkombinationen II'
|
||||
challengeType: 1
|
||||
forumTopicId: 301741
|
||||
dashedName: problem-115-counting-block-combinations-ii
|
||||
@@ -8,23 +8,23 @@ dashedName: problem-115-counting-block-combinations-ii
|
||||
|
||||
# --description--
|
||||
|
||||
A row measuring `n` units in length has red blocks with a minimum length of `m` units placed on it, such that any two red blocks (which are allowed to be different lengths) are separated by at least one black square.
|
||||
Auf eine Reihe mit einer Länge von `n` Einheiten werden rote Blöcke mit einer Mindestlänge von `m` Einheiten gelegt, so dass zwei rote Blöcke (die unterschiedlich lang sein dürfen) durch mindestens ein schwarzes Quadrat getrennt sind.
|
||||
|
||||
Let the fill-count function, $F(m, n)$, represent the number of ways that a row can be filled.
|
||||
Die Füllfunktion $F(m, n)$ soll die Anzahl der Möglichkeiten darstellen, wie eine Zeile gefüllt werden kann.
|
||||
|
||||
For example, $F(3, 29) = 673135$ and $F(3, 30) = 1089155$.
|
||||
Zum Beispiel $F(3, 29) = 673135$ und $F(3, 30) = 1089155$.
|
||||
|
||||
That is, for m = 3, it can be seen that n = 30 is the smallest value for which the fill-count function first exceeds one million.
|
||||
Das heißt, für m = 3 ist n = 30 der kleinste Wert, für den die Fill-Count-Funktion erstmals eine Million überschreitet.
|
||||
|
||||
In the same way, for m = 10, it can be verified that $F(10, 56) = 880711$ and $F(10, 57) = 1148904$, so n = 57 is the least value for which the fill-count function first exceeds one million.
|
||||
Auf die gleiche Weise kann für m = 10 nachgewiesen werden, dass $F(10, 56) = 880711$ und $F(10, 57) = 1148904$, also n = 57 der kleinste Wert ist, für den die Fill-Count-Funktion erstmals eine Million überschreitet.
|
||||
|
||||
For m = 50, find the least value of `n` for which the fill-count function first exceeds one million.
|
||||
Finde für m = 50 den kleinsten Wert von `n`, für den die Funktion fill-count zuerst eine Million überschreitet.
|
||||
|
||||
**Note:** This is a more difficult version of Problem 114.
|
||||
**Hinweis:** Dies ist eine schwierigere Version von Problem 114.
|
||||
|
||||
# --hints--
|
||||
|
||||
`countingBlockTwo()` should return `168`.
|
||||
`countingBlockTwo()` sollte `168` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(countingBlockTwo(), 168);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3e01000cf542c50fef3
|
||||
title: 'Problem 116: Red, green or blue tiles'
|
||||
title: 'Problem 116: Rote, grüne oder blaue Fliesen'
|
||||
challengeType: 1
|
||||
forumTopicId: 301742
|
||||
dashedName: problem-116-red-green-or-blue-tiles
|
||||
@@ -8,7 +8,7 @@ dashedName: problem-116-red-green-or-blue-tiles
|
||||
|
||||
# --description--
|
||||
|
||||
A row of five black square tiles is to have a number of its tiles replaced with coloured oblong tiles chosen from red (length two), green (length three), or blue (length four).
|
||||
Bei einer Reihe von fünf schwarzen quadratischen Steinen wird eine bestimmte Anzahl von Spielsteinen durch farbige längliche Spielsteine ersetzt, die entweder rot (Länge zwei), grün (Länge drei) oder blau (Länge vier) sind.
|
||||
|
||||
If red tiles are chosen there are exactly seven ways this can be done.
|
||||
|
||||
@@ -16,19 +16,19 @@ If red tiles are chosen there are exactly seven ways this can be done.
|
||||
|
||||
If green tiles are chosen there are three ways.
|
||||
|
||||
<img class="img-responsive center-block" alt="Possible ways of placing green oblong on a row with length of five units" src="https://cdn.freecodecamp.org/curriculum/project-euler/red-green-or-blue-tiles-2.png" style="background-color: white; padding: 10px;" />
|
||||
<img class="img-responsive center-block" alt="Möglichkeiten, das grüne Rechteck in einer Reihe mit einer Länge von fünf Einheiten zu platzieren" src="https://cdn.freecodecamp.org/curriculum/project-euler/red-green-or-blue-tiles-2.png" style="background-color: white; padding: 10px;" />
|
||||
|
||||
And if blue tiles are chosen there are two ways.
|
||||
Und wenn blaue Steine gewählt werden, gibt es zwei Möglichkeiten.
|
||||
|
||||
<img class="img-responsive center-block" alt="Possible ways of placing blue oblong on a row with length of five units" src="https://cdn.freecodecamp.org/curriculum/project-euler/red-green-or-blue-tiles-3.png" style="background-color: white; padding: 10px;" />
|
||||
<img class="img-responsive center-block" alt="Möglichkeiten, das blaue Rechteck in einer Reihe mit einer Länge von fünf Einheiten zu platzieren" src="https://cdn.freecodecamp.org/curriculum/project-euler/red-green-or-blue-tiles-3.png" style="background-color: white; padding: 10px;" />
|
||||
|
||||
Assuming that colors cannot be mixed there are 7 + 3 + 2 = 12 ways of replacing the black tiles in a row measuring five units in length. How many different ways can the black tiles in a row measuring fifty units in length be replaced if colors cannot be mixed and at least one colored tile must be used?
|
||||
Unter der Annahme, dass Farben nicht gemischt werden können, gibt es 7 + 3 + 2 = 12 Möglichkeiten, die schwarzen Steine in einer Reihe von fünf Einheiten Länge zu ersetzen. Auf wie viele verschiedene Arten können die schwarzen Steine in einer Reihe von fünfzig Einheiten Länge ersetzt werden, wenn die Farben nicht gemischt werden können und mindestens ein farbiger Stein verwendet werden muss?
|
||||
|
||||
**Note:** This is related to Problem 117.
|
||||
**Hinweis:** Dies bezieht sich auf Problem 117.
|
||||
|
||||
# --hints--
|
||||
|
||||
`redGreenBlueOne()` should return `20492570929`.
|
||||
`redGreenBlueOne()` sollte `20492570929` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(redGreenBlueOne(), 20492570929);
|
||||
|
||||
@@ -8,17 +8,17 @@ dashedName: problem-117-red-green-and-blue-tiles
|
||||
|
||||
# --description--
|
||||
|
||||
Using a combination of black square tiles and oblong tiles chosen from: red tiles measuring two units, green tiles measuring three units, and blue tiles measuring four units, it is possible to tile a row measuring five units in length in exactly fifteen different ways.
|
||||
Mit einer Kombination aus schwarzen quadratischen Steinen und länglichen Steinen, ausgewählt aus roten Steinen mit einer Größe von zwei Einheiten, grünen Steinen mit einer Größe von drei Einheiten und blauen Steinen mit einer Größe von vier Einheiten, ist es möglich, eine Reihe mit einer Länge von fünf Einheiten auf genau fünfzehn verschiedene Arten zu verlegen.
|
||||
|
||||
<img class="img-responsive center-block" alt="Possible ways of placing red, green and blue oblongs on a row with length of five units" src="https://cdn.freecodecamp.org/curriculum/project-euler/red-green-and-blue-tiles.png" style="background-color: white; padding: 10px;" />
|
||||
<img class="img-responsive center-block" alt="Möglichkeiten, rote, grüne und blaue Rechtecke in einer Reihe mit einer Länge von fünf Einheiten zu platzieren" src="https://cdn.freecodecamp.org/curriculum/project-euler/red-green-and-blue-tiles.png" style="background-color: white; padding: 10px;" />
|
||||
|
||||
How many ways can a row measuring fifty units in length be tiled?
|
||||
Auf wie viele Arten kann eine Reihe mit einer Länge von fünfzig Einheiten übereinander gelegt werden?
|
||||
|
||||
**Note**: This is related to Problem 116.
|
||||
**Hinweis**: Dies hängt mit Problem 116 zusammen.
|
||||
|
||||
# --hints--
|
||||
|
||||
`redGreenBlueTilesTwo()` should return `100808458960497`.
|
||||
`redGreenBlueTilesTwo()` sollte `100808458960497` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(redGreenBlueTilesTwo(), 100808458960497);
|
||||
|
||||
@@ -8,13 +8,13 @@ dashedName: problem-118-pandigital-prime-sets
|
||||
|
||||
# --description--
|
||||
|
||||
Using all of the digits 1 through 9 and concatenating them freely to form decimal integers, different sets can be formed. Interestingly with the set $\\{2, 5, 47, 89, 631\\}$, all of the elements belonging to it are prime.
|
||||
Wenn man alle Ziffern von 1 bis 9 verwendet und sie frei zu Dezimalzahlen verkettet, können verschiedene Mengen gebildet werden. Interessanterweise sind alle Elemente, die zur Menge $\\{2, 5, 47, 89, 631\\}$ gehören, Primzahlen.
|
||||
|
||||
How many distinct sets containing each of the digits one through nine exactly once contain only prime elements?
|
||||
Wie viele unterschiedliche Mengen, die jede der Ziffern eins bis neun genau einmal enthalten, enthalten nur Primzahlen?
|
||||
|
||||
# --hints--
|
||||
|
||||
`pandigitalPrimeSets()` should return `44680`.
|
||||
`pandigitalPrimeSets()` sollte `44680` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(pandigitalPrimeSets(), 44680);
|
||||
|
||||
@@ -8,17 +8,17 @@ dashedName: problem-119-digit-power-sum
|
||||
|
||||
# --description--
|
||||
|
||||
The number 512 is interesting because it is equal to the sum of its digits raised to some power: $5 + 1 + 2 = 8$, and $8^3 = 512$. Another example of a number with this property is $614656 = 28^4$.
|
||||
Die Zahl 512 ist interessant, weil sie gleich der Summe ihrer Ziffern in einer Potenz ist: $5 + 1 + 2 = 8$, und $8^3 = 512$. Ein weiteres Beispiel für eine Zahl mit dieser Eigenschaft ist $614656 = 28^4$.
|
||||
|
||||
We shall define $a_n$ to be the $n-th$ term of this sequence and insist that a number must contain at least two digits to have a sum.
|
||||
Wir definieren $a_n$ als den $n-th$ Term dieser Folge und bestehen darauf, dass eine Zahl mindestens zwei Ziffern enthalten muss, um eine Summe zu haben.
|
||||
|
||||
You are given that $a_2 = 512$ and $a_{10} = 614656$.
|
||||
Es ist gegeben, dass $a_2 = 512$ und $a_{10} = 614656$.
|
||||
|
||||
Find $a_{30}$.
|
||||
Finde $a_{30}$.
|
||||
|
||||
# --hints--
|
||||
|
||||
`digitPowerSum()` should return `248155780267521`.
|
||||
`digitPowerSum()` sollte `248155780267521` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(digitPowerSum(), 248155780267521);
|
||||
|
||||
@@ -10,13 +10,13 @@ dashedName: problem-120-square-remainders
|
||||
|
||||
Let `r` be the remainder when ${(a − 1)}^n + {(a + 1)}^n$ is divided by $a^2$.
|
||||
|
||||
For example, if $a = 7$ and $n = 3$, then $r = 42: 6^3 + 8^3 = 728 ≡ 42 \\ \text{mod}\\ 49$. And as `n` varies, so too will `r`, but for $a = 7$ it turns out that $r_{max} = 42$.
|
||||
Wenn zum Beispiel $a = 7$ und $n = 3$, dann ist $r = 42: 6^3 + 8^3 = 728 ≡ 42 \\ \text{mod}\ 49$. Und so wie `n` variiert, so wird auch `r` variieren, aber für $a = 7$ stellt sich heraus, dass $r_{max} = 42$ ist.
|
||||
|
||||
For $3 ≤ a ≤ 1000$, find $\sum{r}_{max}$.
|
||||
Für $3 ≤ a ≤ 1000$, finde $\sum{r}_{max}$.
|
||||
|
||||
# --hints--
|
||||
|
||||
`squareRemainders()` should return `333082500`.
|
||||
`squareRemainders()` sollte `333082500` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(squareRemainders(), 333082500);
|
||||
|
||||
@@ -8,17 +8,17 @@ dashedName: problem-121-disc-game-prize-fund
|
||||
|
||||
# --description--
|
||||
|
||||
A bag contains one red disc and one blue disc. In a game of chance a player takes a disc at random and its colour is noted. After each turn the disc is returned to the bag, an extra red disc is added, and another disc is taken at random.
|
||||
Ein Beutel enthält eine rote Scheibe und eine blaue Scheibe. In einem Glücksspiel zieht ein Spieler eine zufällige Scheibe und deren Farbe wird notiert. Nach jeder Runde wird die Scheibe zurück in den Beutel gelegt, eine zusätzliche rote Scheibe wird hinzugefügt, und eine andere Scheibe wird zufällig entnommen.
|
||||
|
||||
The player pays £1 to play and wins if they have taken more blue discs than red discs at the end of the game.
|
||||
Der Spieler zahlt £1, um zu spielen und gewinnt, wenn am Ende des Spiels mehr blaue als rote Scheiben entnommen wurden.
|
||||
|
||||
If the game is played for four turns, the probability of a player winning is exactly 11/120, and so the maximum prize fund the banker should allocate for winning in this game would be £10 before they would expect to incur a loss. Note that any payout will be a whole number of pounds and also includes the original £1 paid to play the game, so in the example given the player actually wins £9.
|
||||
Wenn das Spiel in vier Runden gespielt wird, liegt die Wahrscheinlichkeit, dass ein Spieler gewinnt, bei genau 11/120, und der maximale Preisfonds, den der Bankier für einen Gewinn in diesem Spiel bereitstellen sollte, würde so 10 £ betragen, bevor ein Verlust erwartet werden würde. Zu beachten ist, dass jede Auszahlung eine ganze Zahl von Pfund ist und auch die ursprünglich für das Spiel gezahlten 1 Pfund einschließt, so dass der Spieler in dem angegebenen Beispiel tatsächlich 9 Pfund gewinnt.
|
||||
|
||||
Find the maximum prize fund that should be allocated to a single game in which fifteen turns are played.
|
||||
Finde die maximale Prämie, die in einem einzigen Spiel zugewiesen werden sollte, in dem 15 Runden gespielt werden.
|
||||
|
||||
# --hints--
|
||||
|
||||
`discGamePrize()` should return `2269`.
|
||||
`discGamePrize()` sollte `2269` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(discGamePrize(), 2269);
|
||||
|
||||
@@ -12,26 +12,26 @@ The most naive way of computing $n^{15}$ requires fourteen multiplications:
|
||||
|
||||
$$n × n × \ldots × n = n^{15}$$
|
||||
|
||||
But using a "binary" method you can compute it in six multiplications:
|
||||
Mit einer "binären" Methode kann man sie jedoch in sechs Multiplikationen berechnen:
|
||||
|
||||
$$\begin{align} & n × n = n^2\\\\
|
||||
& n^2 × n^2 = n^4\\\\ & n^4 × n^4 = n^8\\\\
|
||||
& n^8 × n^4 = n^{12}\\\\ & n^{12} × n^2 = n^{14}\\\\
|
||||
& n^{14} × n = n^{15} \end{align}$$
|
||||
|
||||
However it is yet possible to compute it in only five multiplications:
|
||||
Es ist jedoch möglich, ihn in nur fünf Multiplikationen zu berechnen:
|
||||
|
||||
$$\begin{align} & n × n = n^2\\\\
|
||||
& n^2 × n = n^3\\\\ & n^3 × n^3 = n^6\\\\
|
||||
& n^6 × n^6 = n^{12}\\\\ & n^{12} × n^3 = n^{15} \end{align}$$
|
||||
|
||||
We shall define $m(k)$ to be the minimum number of multiplications to compute $n^k$; for example $m(15) = 5$.
|
||||
Wir definieren $m(k)$ als die minimale Anzahl von Multiplikationen zur Berechnung von $n^k$; zum Beispiel $m(15) = 5$.
|
||||
|
||||
For $1 ≤ k ≤ 200$, find $\sum{m(k)}$.
|
||||
Für $1 ≤ k ≤ 200$, finde $\sum{m(k)}$.
|
||||
|
||||
# --hints--
|
||||
|
||||
`efficientExponentation()` should return `1582`.
|
||||
`efficientExponentation()` sollte `1582` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(efficientExponentation(), 1582);
|
||||
|
||||
@@ -10,15 +10,15 @@ dashedName: problem-123-prime-square-remainders
|
||||
|
||||
Let $p_n$ be the $n$th prime: 2, 3, 5, 7, 11, ..., and let $r$ be the remainder when ${(p_n−1)}^n + {(p_n+1)}^n$ is divided by ${p_n}^2$.
|
||||
|
||||
For example, when $n = 3, p_3 = 5$, and $4^3 + 6^3 = 280 ≡ 5\\ mod\\ 25$.
|
||||
Zum Beispiel, wenn $n = 3, p_3 = 5$, und $4^3 + 6^3 = 280 ≡ 5\\ mod\ 25$.
|
||||
|
||||
The least value of $n$ for which the remainder first exceeds $10^9$ is 7037.
|
||||
Der kleinste Wert von $n$, für den der Rest zuerst $10^9$ überschreitet, ist 7037.
|
||||
|
||||
Find the least value of $n$ for which the remainder first exceeds $10^{10}$.
|
||||
Finde den kleinsten Wert von $n$, für den der Rest zuerst $10^{10}$ überschreitet.
|
||||
|
||||
# --hints--
|
||||
|
||||
`primeSquareRemainders()` should return `21035`.
|
||||
`primeSquareRemainders()` sollte `21035` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(primeSquareRemainders(), 21035);
|
||||
|
||||
@@ -112,11 +112,11 @@ If we calculate $rad(n)$ for $1 ≤ n ≤ 10$, then sort them on $rad(n)$, and s
|
||||
</table>
|
||||
</div><br>
|
||||
|
||||
Let $E(k)$ be the $k$th element in the sorted $n$ column; for example, $E(4) = 8$ and $E(6) = 9$. If $rad(n)$ is sorted for $1 ≤ n ≤ 100000$, find $E(10000)$.
|
||||
Lasse $E(k)$ das $k$th Element in der geordneten $n$ Spalte sein; zum Beispiel, $E(4) = 8$ und $E(6) = 9$. Wenn $rad(n)$ für $1 ≤ n ≤ 100000$ geordnet ist, findest du $E(10000)$.
|
||||
|
||||
# --hints--
|
||||
|
||||
`orderedRadicals()` should return `21417`.
|
||||
`orderedRadicals()` sollte `21417` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(orderedRadicals(), 21417);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3e91000cf542c50fefc
|
||||
title: 'Problem 125: Palindromic sums'
|
||||
title: 'Problem 125: Palindromische Summen'
|
||||
challengeType: 1
|
||||
forumTopicId: 301752
|
||||
dashedName: problem-125-palindromic-sums
|
||||
@@ -8,14 +8,14 @@ dashedName: problem-125-palindromic-sums
|
||||
|
||||
# --description--
|
||||
|
||||
The palindromic number 595 is interesting because it can be written as the sum of consecutive squares: $6^2 + 7^2 + 8^2 + 9^2 + 10^2 + 11^2 + 12^2$.
|
||||
Die palindromische Zahl 595 ist interessant, weil sie als Summe aufeinander folgender Quadrate geschrieben werden kann: $6^2 + 7^2 + 8^2 + 9^2 + 10^2 + 11^2 + 11^2 + 12^2$.
|
||||
|
||||
There are exactly eleven palindromes below one-thousand that can be written as consecutive square sums, and the sum of these palindromes is 4164. Note that $1 = 0^2 + 1^2$ has not been included as this problem is concerned with the squares of positive integers.
|
||||
Es gibt genau elf Palindrome unter eintausend, die als aufeinanderfolgende Quadratsummen geschrieben werden können, und die Summe dieser Palindrome ist 4164. Man beachte, dass $1 = 0^2 + 1^2$ nicht berücksichtigt wurde, da es sich bei diesem Problem um die Quadrate positiver ganzer Zahlen handelt.
|
||||
|
||||
Find the sum of all the numbers less than the `limit` that are both palindromic and can be written as the sum of consecutive squares.
|
||||
Finde die Summe aller Zahlen, die kleiner als `limit` sind, die beide palindromisch sind und als Summe aufeinanderfolgender Quadrate geschrieben werden können.
|
||||
|
||||
# --hints--
|
||||
`palindromicSums(100000000)` should return `2906969179`.
|
||||
`palindromicSums(100000000)` sollte `2906969179` zurückgeben.
|
||||
|
||||
```js
|
||||
|
||||
@@ -23,13 +23,13 @@ assert.strictEqual(palindromicSums(100000000), 2906969179);
|
||||
|
||||
```
|
||||
|
||||
`palindromicSums(100)` should return `137`.
|
||||
`palindromicSums(100)` sollte `137` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(palindromicSums(100), 137);
|
||||
```
|
||||
|
||||
`palindromicSums(1000)` should return `4164`.
|
||||
`palindromicSums(1000)` sollte `4164` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(palindromicSums(1000),4164);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3ea1000cf542c50fefd
|
||||
title: 'Problem 126: Cuboid layers'
|
||||
title: 'Problem 126: Quaderförmige Ebenen'
|
||||
challengeType: 1
|
||||
forumTopicId: 301753
|
||||
dashedName: problem-126-cuboid-layers
|
||||
@@ -12,19 +12,19 @@ The minimum number of cubes to cover every visible face on a cuboid measuring 3
|
||||
|
||||
<img class="img-responsive center-block" alt="3x2x1 cuboid covered by twenty-two 1x1x1 cubes" src="https://cdn.freecodecamp.org/curriculum/project-euler/cuboid-layers.png" style="background-color: white; padding: 10px;" />
|
||||
|
||||
If we add a second layer to this solid it would require forty-six cubes to cover every visible face, the third layer would require seventy-eight cubes, and the fourth layer would require one-hundred and eighteen cubes to cover every visible face.
|
||||
Fügen wir diesem Körper eine zweite Schicht hinzu, wären sechsundvierzig Würfel erforderlich, um jede sichtbare Fläche zu bedecken, für die dritte Schicht wären achtundsiebzig Würfel erforderlich, und für die vierte Schicht wären einhundertachtzehn Würfel erforderlich, um jede sichtbare Fläche zu bedecken.
|
||||
|
||||
However, the first layer on a cuboid measuring 5 x 1 x 1 also requires twenty-two cubes; similarly, the first layer on cuboids measuring 5 x 3 x 1, 7 x 2 x 1, and 11 x 1 x 1 all contain forty-six cubes.
|
||||
Für die erste Schicht auf einem Quader mit den Maßen 5 x 1 x 1 werden jedoch auch zweiundzwanzig Würfel benötigt; ebenso enthält die erste Schicht auf Quadern mit den Maßen 5 x 3 x 1, 7 x 2 x 1 und 11 x 1 x 1 jeweils sechsundvierzig Würfel.
|
||||
|
||||
We shall define $C(n)$ to represent the number of cuboids that contain $n$ cubes in one of its layers. So $C(22) = 2$, $C(46) = 4$, $C(78) = 5$, and $C(118) = 8$.
|
||||
Wir definieren $C(n)$ als die Anzahl der Quader, die $n$ Würfel in einer ihrer Schichten enthalten. Also $C(22) = 2$, $C(46) = 4$, $C(78) = 5$, und $C(118) = 8$.
|
||||
|
||||
It turns out that 154 is the least value of $n$ for which $C(n) = 10$.
|
||||
Es stellt sich heraus, dass 154 der kleinste Wert von $n$ ist, für den $C(n) = 10$ ist.
|
||||
|
||||
Find the least value of $n$ for which $C(n) = 1000$.
|
||||
Finde den kleinsten Wert von $n$, für den $C(n) = 1000$ ist.
|
||||
|
||||
# --hints--
|
||||
|
||||
`cuboidLayers()` should return `18522`.
|
||||
`cuboidLayers()` sollte `18522` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(cuboidLayers(), 18522);
|
||||
|
||||
@@ -8,29 +8,29 @@ dashedName: problem-127-abc-hits
|
||||
|
||||
# --description--
|
||||
|
||||
The radical of $n$, $rad(n)$, is the product of distinct prime factors of $n$. For example, $504 = 2^3 × 3^2 × 7$, so $rad(504) = 2 × 3 × 7 = 42$.
|
||||
The radical of $n$, $rad(n)$, is the product of distinct prime factors of $n$. Zum Beispiel: $504 = 2^3 × 3^2 × 7$, also $rad(504) = 2 × 3 × 7 = 42$.
|
||||
|
||||
We shall define the triplet of positive integers (a, b, c) to be an abc-hit if:
|
||||
Wir definieren das Tripel positiver ganzer Zahlen (a, b, c) als einen abc-Treffer, wenn:
|
||||
|
||||
1. $GCD(a, b) = GCD(a, c) = GCD(b, c) = 1$
|
||||
2. $a < b$
|
||||
3. $a + b = c$
|
||||
4. $rad(abc) < c$
|
||||
|
||||
For example, (5, 27, 32) is an abc-hit, because:
|
||||
Zum Beispiel ist (5, 27, 32) ein abc-Treffer, weil:
|
||||
|
||||
1. $GCD(5, 27) = GCD(5, 32) = GCD(27, 32) = 1$
|
||||
2. $5 < 27$
|
||||
3. $5 + 27 = 32$
|
||||
4. $rad(4320) = 30 < 32$
|
||||
|
||||
It turns out that abc-hits are quite rare and there are only thirty-one abc-hits for $c < 1000$, with $\sum{c} = 12523$.
|
||||
Es stellt sich heraus, dass abc-Treffer recht selten sind und es nur einunddreißig abc-Treffer für $c < 1000$ gibt, mit $\sum{c} = 12523$.
|
||||
|
||||
Find $\sum{c}$ for $c < 120000$.
|
||||
Finde $\sum{c}$ für $c < 120000$.
|
||||
|
||||
# --hints--
|
||||
|
||||
`abcHits()` should return `18407904`.
|
||||
`abcHits()` sollte `18407904` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(abcHits(), 18407904);
|
||||
|
||||
@@ -10,17 +10,17 @@ dashedName: problem-128-hexagonal-tile-differences
|
||||
|
||||
A hexagonal tile with number 1 is surrounded by a ring of six hexagonal tiles, starting at "12 o'clock" and numbering the tiles 2 to 7 in an anti-clockwise direction.
|
||||
|
||||
New rings are added in the same fashion, with the next rings being numbered 8 to 19, 20 to 37, 38 to 61, and so on. The diagram below shows the first three rings.
|
||||
Neue Ringe werden auf die gleiche Weise hinzugefügt, wobei die nächsten Ringe die Nummern 8 bis 19, 20 bis 37, 38 bis 61 usw. tragen. Das folgende Diagramm zeigt die ersten drei Ringe.
|
||||
|
||||
<img class="img-responsive center-block" alt="three first rings of arranged hexagonal tiles with numbers 1 to 37, and with highlighted tiles 8 and 17" src="https://cdn.freecodecamp.org/curriculum/project-euler/hexagonal-tile-differences.png" style="background-color: white; padding: 10px;" />
|
||||
<img class="img-responsive center-block" alt="drei erste Ringe aus angeordneten sechseckigen Steinen mit den Nummern 1 bis 37 und den hervorgehobenen Steinen 8 und 17" src="https://cdn.freecodecamp.org/curriculum/project-euler/hexagonal-tile-differences.png" style="background-color: white; padding: 10px;" />
|
||||
|
||||
By finding the difference between tile $n$ and each of its six neighbours we shall define $PD(n)$ to be the number of those differences which are prime.
|
||||
|
||||
For example, working clockwise around tile 8 the differences are 12, 29, 11, 6, 1, and 13. So $PD(8) = 3$.
|
||||
For example, working clockwise around tile 8 the differences are 12, 29, 11, 6, 1, and 13. Somit ist $PD(8) = 3$.
|
||||
|
||||
In the same way, the differences around tile 17 are 1, 17, 16, 1, 11, and 10, hence $PD(17) = 2$.
|
||||
|
||||
It can be shown that the maximum value of $PD(n)$ is $3$.
|
||||
Es kann gezeigt werden, dass der Maximalwert von $PD(n)$ $ $3$ ist.
|
||||
|
||||
If all of the tiles for which $PD(n) = 3$ are listed in ascending order to form a sequence, the 10th tile would be 271.
|
||||
|
||||
@@ -28,13 +28,13 @@ Find the 2000th tile in this sequence.
|
||||
|
||||
# --hints--
|
||||
|
||||
`hexagonalTile(10)` should return `271`.
|
||||
`hexagonalTile(10)` sollte `271` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(hexagonalTile(10), 271);
|
||||
```
|
||||
|
||||
`hexagonalTile(2000)` should return `14516824220`.
|
||||
`hexagonalTile(2000)` sollte `14516824220` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(hexagonalTile(2000), 14516824220);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3ef1000cf542c50ff01
|
||||
title: 'Problem 129: Repunit divisibility'
|
||||
title: 'Problem 129: Teilbarkeit von Einheiten'
|
||||
challengeType: 1
|
||||
forumTopicId: 301756
|
||||
dashedName: problem-129-repunit-divisibility
|
||||
@@ -8,17 +8,17 @@ dashedName: problem-129-repunit-divisibility
|
||||
|
||||
# --description--
|
||||
|
||||
A number consisting entirely of ones is called a repunit. We shall define $R(k)$ to be a repunit of length $k$; for example, $R(6) = 111111$.
|
||||
Eine Zahl, die ausschließlich aus Einsen besteht, nennt man ein Repunit. We shall define $R(k)$ to be a repunit of length $k$; for example, $R(6) = 111111$.
|
||||
|
||||
Given that $n$ is a positive integer and $GCD(n, 10) = 1$, it can be shown that there always exists a value, $k$, for which $R(k)$ is divisible by $n$, and let $A(n)$ be the least such value of $k$; for example, $A(7) = 6$ and $A(41) = 5$.
|
||||
Unter der Voraussetzung, dass $n$ eine positive ganze Zahl ist und $GCD(n, 10) = 1$, kann man zeigen, dass es immer einen Wert $k$ gibt, für den $R(k)$ durch $n$ teilbar ist, und dass $A(n)$ der kleinste solche Wert von $k$ ist; zum Beispiel $A(7) = 6$ und $A(41) = 5$.
|
||||
|
||||
The least value of $n$ for which $A(n)$ first exceeds ten is 17.
|
||||
Der kleinste Wert von $n$, für den $A(n)$ zuerst zehn überschreitet, ist 17.
|
||||
|
||||
Find the least value of $n$ for which $A(n)$ first exceeds one-million.
|
||||
Finde den kleinsten Wert von $n$, für den $A(n)$ zuerst eine Million überschreitet.
|
||||
|
||||
# --hints--
|
||||
|
||||
`repunitDivisibility()` should return `1000023`.
|
||||
`repunitDivisibility()` sollte `1000023` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(repunitDivisibility(), 1000023);
|
||||
|
||||
@@ -8,19 +8,19 @@ dashedName: problem-130-composites-with-prime-repunit-property
|
||||
|
||||
# --description--
|
||||
|
||||
A number consisting entirely of ones is called a repunit. We shall define $R(k)$ to be a repunit of length $k$; for example, $R(6) = 111111$.
|
||||
Eine Zahl, die ausschließlich aus Einsen besteht, nennt man Repunit. Wir definieren $R(k)$ als Repunit der Länge $k$; zum Beispiel $R(6) = 111111$.
|
||||
|
||||
Given that $n$ is a positive integer and $GCD(n, 10) = 1$, it can be shown that there always exists a value, $k$, for which $R(k)$ is divisible by $n$, and let $A(n)$ be the least such value of $k$; for example, $A(7) = 6$ and $A(41) = 5$.
|
||||
Unter der Voraussetzung, dass $n$ eine positive ganze Zahl ist und $GCD(n, 10) = 1$, kann man zeigen, dass es immer einen Wert $k$ gibt, für den $R(k)$ durch $n$ teilbar ist, und dass $A(n)$ der kleinste solche Wert von $k$ ist; zum Beispiel $A(7) = 6$ und $A(41) = 5$.
|
||||
|
||||
You are given that for all primes, $p > 5$, that $p − 1$ is divisible by $A(p)$. For example, when $p = 41, A(41) = 5$, and 40 is divisible by 5.
|
||||
Es ist gegeben, dass für alle Primzahlen $p > 5$, dass $p - 1$ durch $A(p)$ teilbar ist. Wenn zum Beispiel $p = 41 ist, ist A(41) = 5$, und 40 durch 5 teilbar.
|
||||
|
||||
However, there are rare composite values for which this is also true; the first five examples being 91, 259, 451, 481, and 703.
|
||||
Es gibt jedoch seltene zusammengesetzte Werte, für die dies ebenfalls zutrifft; die ersten fünf Beispiele sind 91, 259, 451, 481 und 703.
|
||||
|
||||
Find the sum of the first twenty-five composite values of $n$ for which $GCD(n, 10) = 1$ and $n − 1$ is divisible by $A(n)$.
|
||||
Finde die Summe der ersten fünfundzwanzig zusammengesetzten Werte von $n$, für die $GCD(n, 10) = 1$ und $n - 1$ durch $A(n)$ teilbar ist.
|
||||
|
||||
# --hints--
|
||||
|
||||
`compositeRepunit()` should return `149253`.
|
||||
`compositeRepunit()` sollte `149253` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(compositeRepunit(), 149253);
|
||||
|
||||
@@ -8,17 +8,17 @@ dashedName: problem-131-prime-cube-partnership
|
||||
|
||||
# --description--
|
||||
|
||||
There are some prime values, $p$, for which there exists a positive integer, $n$, such that the expression $n^3 + n^{2}p$ is a perfect cube.
|
||||
Es gibt einige Primzahlen $p$, für die es eine positive ganze Zahl $n$ gibt, sodass der Ausdruck $n^3 + n^{2}p$ ein perfekter Würfel ist.
|
||||
|
||||
For example, when $p = 19,\\ 8^3 + 8^2 × 19 = {12}^3$.
|
||||
Zum Beispiel, wenn $p = 19,\\ 8^3 + 8^2 × 19 = {12}^3$.
|
||||
|
||||
What is perhaps most surprising is that the value of $n$ is unique for each prime with this property, and there are only four such primes below one hundred.
|
||||
Was vielleicht am meisten überrascht, ist, dass der Wert von $n$ für jede Primzahl mit dieser Eigenschaft einzigartig ist, und dass es nur vier solcher Primzahlen unter hundert gibt.
|
||||
|
||||
How many primes below one million have this remarkable property?
|
||||
Wie viele Primzahlen unter einer Million haben diese bemerkenswerte Eigenschaft?
|
||||
|
||||
# --hints--
|
||||
|
||||
`primeCubePartnership()` should return `173`.
|
||||
`primeCubePartnership()` sollte `173` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(primeCubePartnership(), 173);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3f11000cf542c50ff03
|
||||
title: 'Problem 132: Large repunit factors'
|
||||
title: 'Problem 132: Große Repunit-Faktoren'
|
||||
challengeType: 1
|
||||
forumTopicId: 301760
|
||||
dashedName: problem-132-large-repunit-factors
|
||||
@@ -8,15 +8,15 @@ dashedName: problem-132-large-repunit-factors
|
||||
|
||||
# --description--
|
||||
|
||||
A number consisting entirely of ones is called a repunit. We shall define $R(k)$ to be a repunit of length $k$.
|
||||
Eine Zahl, die alleinig aus Einsen besteht, wird Repunit genannt. We shall define $R(k)$ to be a repunit of length $k$.
|
||||
|
||||
For example, $R(10) = 1111111111 = 11 × 41 × 271 × 9091$, and the sum of these prime factors is 9414.
|
||||
Zum Beispiel gilt, dass $R(10) = 1111111111 = 11 × 41 × 271 × 9091$ und die Summe dieser Primfaktoren 9414 ist.
|
||||
|
||||
Find the sum of the first forty prime factors of $R({10}^9)$.
|
||||
Finde die Summe der ersten 40 Primfaktoren von $R({10}^9)$.
|
||||
|
||||
# --hints--
|
||||
|
||||
`largeRepunitFactors()` should return `843296`.
|
||||
`largeRepunitFactors()` sollte `843296` ausgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(largeRepunitFactors(), 843296);
|
||||
|
||||
@@ -8,17 +8,17 @@ dashedName: problem-133-repunit-nonfactors
|
||||
|
||||
# --description--
|
||||
|
||||
A number consisting entirely of ones is called a repunit. We shall define $R(k)$ to be a repunit of length $k$; for example, $R(6) = 111111$.
|
||||
Eine Zahl, die ausschließlich aus Einsen besteht, nennt man Repunit. Wir definieren $R(k)$ als Repunit der Länge $k$; zum Beispiel $R(6) = 111111$.
|
||||
|
||||
Let us consider repunits of the form $R({10}^n)$.
|
||||
Wir betrachten Repunits in der Form $R({10}^n)$.
|
||||
|
||||
Although $R(10)$, $R(100)$, or $R(1000)$ are not divisible by 17, $R(10000)$ is divisible by 17. Yet there is no value of n for which $R({10}^n)$ will divide by 19. Remarkably, 11, 17, 41, and 73 are the only four primes below one-hundred that can be a factor of $R({10}^n)$.
|
||||
Obwohl $R(10)$, $R(100)$ oder $R(1000)$ nicht durch 17 teilbar sind, ist $R(10000)$ durch 17 teilbar. Es gibt jedoch keinen Wert von n, für den $R({10}^n)$ durch 19 teilbar wäre. Bemerkenswerterweise sind 11, 17, 41 und 73 die einzigen vier Primzahlen unter Hundert, die ein Faktor von $R({10}^n)$ sein können.
|
||||
|
||||
Find the sum of all the primes below one-hundred thousand that will never be a factor of $R({10}^n)$.
|
||||
Finde die Summe aller Primzahlen unter einhunderttausend, die niemals ein Faktor von $R({10}^n)$ sein wird.
|
||||
|
||||
# --hints--
|
||||
|
||||
`repunitNonfactors()` should return `453647705`.
|
||||
`repunitNonfactors()` sollte `453647705` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(repunitNonfactors(), 453647705);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3f21000cf542c50ff05
|
||||
title: 'Problem 134: Prime pair connection'
|
||||
title: 'Problem 134: Primzahl-Paar-Verbindungen'
|
||||
challengeType: 1
|
||||
forumTopicId: 301762
|
||||
dashedName: problem-134-prime-pair-connection
|
||||
@@ -8,15 +8,15 @@ dashedName: problem-134-prime-pair-connection
|
||||
|
||||
# --description--
|
||||
|
||||
Consider the consecutive primes $p_1 = 19$ and $p_2 = 23$. It can be verified that 1219 is the smallest number such that the last digits are formed by $p_1$ whilst also being divisible by $p_2$.
|
||||
Betrachte die aufeinanderfolgenden Primzahlen $p_1 = 19$ und $p_2 = 23$. Es kann bewiesen werden, dass 1219 die kleinste Zahl ist, so dass die letzten Ziffern mit $p_1$ gebildet werden, während sie auch durch $p_2$ teilbar sind.
|
||||
|
||||
In fact, with the exception of $p_1 = 3$ and $p_2 = 5$, for every pair of consecutive primes, $p_2 > p_1$, there exist values of $n$ for which the last digits are formed by $p_1$ and $n$ is divisible by $p_2$. Let $S$ be the smallest of these values of $n$.
|
||||
Tatsächlich gibt es mit Ausnahme von $p_1 = 3$ und $p_2 = 5$ für jedes Paar von aufeinanderfolgenden Primzahlen $p_2 > p_1$ Werte von $n$, für die die letzten Ziffern durch $p_1$ gebildet werden und $n$ durch $p_2$ teilbar ist. Lass $S$ den kleinsten dieser Werte von $n$ sein.
|
||||
|
||||
Find $\sum{S}$ for every pair of consecutive primes with $5 ≤ p_1 ≤ 1000000$.
|
||||
Finde $\sum{S}$ für jedes Paar der aufeinanderfolgenden Primzahlen mit $5 ≤ p_1 ≤ 1000000$.
|
||||
|
||||
# --hints--
|
||||
|
||||
`primePairConnection()` should return `18613426663617120`.
|
||||
`primePairConnection()` sollte `18613426663617120` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(primePairConnection(), 18613426663617120);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3f31000cf542c50ff06
|
||||
title: 'Problem 135: Same differences'
|
||||
title: 'Problem 135: Gleiche Unterschiede'
|
||||
challengeType: 1
|
||||
forumTopicId: 301763
|
||||
dashedName: problem-135-same-differences
|
||||
@@ -8,17 +8,17 @@ dashedName: problem-135-same-differences
|
||||
|
||||
# --description--
|
||||
|
||||
Given the positive integers, $x$, $y$, and $z$, are consecutive terms of an arithmetic progression, the least value of the positive integer, $n$, for which the equation, $x^2 − y^2 − z^2 = n$, has exactly two solutions is $n = 27$:
|
||||
Da die positiven ganzen Zahlen $x$, $y$ und $z$ aufeinanderfolgende Terme einer arithmetischen Progression sind, ist der kleinste Wert der positiven ganzen Zahl $n$, für den die Gleichung $x^2 - y^2 - z^2 = n$ genau zwei Lösungen hat, $n = 27$:
|
||||
|
||||
$$34^2 − 27^2 − 20^2 = 12^2 − 9^2 − 6^2 = 27$$
|
||||
|
||||
It turns out that $n = 1155$ is the least value which has exactly ten solutions.
|
||||
Es stellt sich heraus, dass $n = 1155$ der kleinste Wert ist, der genau zehn Lösungen hat.
|
||||
|
||||
How many values of $n$ less than one million have exactly ten distinct solutions?
|
||||
Wie viele Werte von $n$, unter einer Million, haben genau zehn verschiedene Lösungen?
|
||||
|
||||
# --hints--
|
||||
|
||||
`sameDifferences()` should return `4989`.
|
||||
`sameDifferences()` sollte `4989` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(sameDifferences(), 4989);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3f51000cf542c50ff07
|
||||
title: 'Problem 136: Singleton difference'
|
||||
title: 'Problem 136: Singleton Unterschied'
|
||||
challengeType: 1
|
||||
forumTopicId: 301764
|
||||
dashedName: problem-136-singleton-difference
|
||||
@@ -8,17 +8,17 @@ dashedName: problem-136-singleton-difference
|
||||
|
||||
# --description--
|
||||
|
||||
The positive integers, $x$, $y$, and $z$, are consecutive terms of an arithmetic progression. Given that $n$ is a positive integer, the equation, $x^2 − y^2 − z^2 = n$, has exactly one solution when $n = 20$:
|
||||
Die positiven ganzen Zahlen $x$, $y$ und $z$ sind aufeinanderfolgende Terme einer arithmetischen Progression. Unter der Voraussetzung, dass $n$ eine positive ganze Zahl ist, hat die Gleichung $x^2 - y^2 - z^2 = n$ genau eine Lösung, wenn $n = 20$:
|
||||
|
||||
$$13^2 − 10^2 − 7^2 = 20$$
|
||||
|
||||
In fact, there are twenty-five values of $n$ below one hundred for which the equation has a unique solution.
|
||||
In der Tat gibt es fünfundzwanzig Werte von $n$ unter hundert, für die die Gleichung eine eindeutige Lösung hat.
|
||||
|
||||
How many values of $n$ less than fifty million have exactly one solution?
|
||||
Wie viele Werte von $n$ kleiner als fünfzig Millionen haben genau eine Lösung?
|
||||
|
||||
# --hints--
|
||||
|
||||
`singletonDifference()` should return `2544559`.
|
||||
`singletonDifference()` sollte `2544559` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(singletonDifference(), 2544559);
|
||||
|
||||
@@ -8,16 +8,16 @@ dashedName: problem-137-fibonacci-golden-nuggets
|
||||
|
||||
# --description--
|
||||
|
||||
Consider the infinite polynomial series $A_{F}(x) = xF_1 + x^2F_2 + x^3F_3 + \ldots$, where $F_k$ is the $k$th term in the Fibonacci sequence: $1, 1, 2, 3, 5, 8, \ldots$; that is, $F_k = F_{k − 1} + F_{k − 2}, F_1 = 1$ and $F_2 = 1$.
|
||||
Man betrachte die unendliche Polynomreihe $A_{F}(x) = xF_1 + x^2F_2 + x^3F_3 + \ldots$, wobei $F_k$ der $k$-te Term der Fibonacci-Folge ist: $1, 1, 2, 3, 5, 8, \ldots$; das heißt, $F_k = F_{k - 1} + F_{k - 2}, F_1 = 1$ und $F_2 = 1$.
|
||||
|
||||
For this problem we shall be interested in values of $x$ for which $A_{F}(x)$ is a positive integer.
|
||||
Für dieses Problem sind wir an Werten von $x$ interessiert, für die $A_{F}(x)$ eine positive ganze Zahl ist.
|
||||
|
||||
Surprisingly
|
||||
Überraschenderweise
|
||||
|
||||
$$\begin{align} A_F(\frac{1}{2}) & = (\frac{1}{2}) × 1 + {(\frac{1}{2})}^2 × 1 + {(\frac{1}{2})}^3 × 2 + {(\frac{1}{2})}^4 × 3 + {(\frac{1}{2})}^5 × 5 + \cdots \\\\
|
||||
& = \frac{1}{2} + \frac{1}{4} + \frac{2}{8} + \frac{3}{16} + \frac{5}{32} + \cdots \\\\ & = 2 \end{align}$$
|
||||
|
||||
The corresponding values of $x$ for the first five natural numbers are shown below.
|
||||
Die entsprechenden Werte von $x$ für die ersten fünf natürlichen Zahlen sind unten dargestellt.
|
||||
|
||||
| $x$ | $A_F(x)$ |
|
||||
| --------------------------- | -------- |
|
||||
@@ -33,7 +33,7 @@ Find the 15th golden nugget.
|
||||
|
||||
# --hints--
|
||||
|
||||
`goldenNugget()` should return `1120149658760`.
|
||||
`goldenNugget()` sollte `1120149658760` zurückgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(goldenNugget(), 1120149658760);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5900f3f61000cf542c50ff09
|
||||
title: 'Problem 138: Special isosceles triangles'
|
||||
title: 'Problem 130: Besondere gleichschenklige Dreiecke'
|
||||
challengeType: 1
|
||||
forumTopicId: 301766
|
||||
dashedName: problem-138-special-isosceles-triangles
|
||||
@@ -10,17 +10,17 @@ dashedName: problem-138-special-isosceles-triangles
|
||||
|
||||
Consider the isosceles triangle with base length, $b = 16$, and legs, $L = 17$.
|
||||
|
||||
<img class="img-responsive center-block" alt="isosceles triangle with edges named as L - two edges with the same length and base of the triangle as b; and height of the triangle - h from the base of the triangle to the angle between L edges" src="https://cdn.freecodecamp.org/curriculum/project-euler/special-isosceles-triangles.png" style="background-color: white; padding: 10px;" />
|
||||
<img class="img-responsive center-block" alt="gleichschenkliges Dreieck mit Kanten, die als L bezeichnet werden - zwei Kanten mit der gleichen Länge und der Basis des Dreiecks wie b; und Höhe des Dreiecks - h von der Basis des Dreiecks bis zum Winkel zwischen den L-Kanten" src="https://cdn.freecodecamp.org/curriculum/project-euler/special-isosceles-triangles.png" style="background-color: white; padding: 10px;" />
|
||||
|
||||
By using the Pythagorean theorem, it can be seen that the height of the triangle, $h = \sqrt{{17}^2 − 8^2} = 15$, which is one less than the base length.
|
||||
Mit Hilfe des Satzes des Pythagoras kannst du feststellen, dass die Höhe des Dreiecks $h = \sqrt{{17}^2 - 8^2} = 15$ ist, also um eins kleiner als die Basislänge.
|
||||
|
||||
With $b = 272$ and $L = 305$, we get $h = 273$, which is one more than the base length, and this is the second smallest isosceles triangle with the property that $h = b ± 1$.
|
||||
Mit $b = 272$ und $L = 305$ erhalten wir $h = 273$, was eins mehr als die Basislänge ist, und dies ist das zweitkleinste gleichschenklige Dreieck mit der Eigenschaft, dass $h = b ± 1$ gilt.
|
||||
|
||||
Find $\sum{L}$ for the twelve smallest isosceles triangles for which $h = b ± 1$ and $b$, $L$ are positive integers.
|
||||
Finde $\sum{L}$ für die zwölf kleinsten gleichschenkligen Dreiecke, für die $h = b ± 1$ gilt und $b$, $L$ positive ganze Zahlen sind.
|
||||
|
||||
# --hints--
|
||||
|
||||
`isoscelesTriangles()` should return `1118049290473932`.
|
||||
`isoscelesTriangles()` sollte `1118049290473932` ausgeben.
|
||||
|
||||
```js
|
||||
assert.strictEqual(isoscelesTriangles(), 1118049290473932);
|
||||
|
||||
@@ -30,7 +30,7 @@ Your first new `p` element should have a `span` element.
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.localName === 'span');
|
||||
```
|
||||
|
||||
Your first `span` element not be bold.
|
||||
Your first `span` element should not be bold.
|
||||
|
||||
```js
|
||||
assert(!document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.classList?.contains('bold'));
|
||||
|
||||
@@ -28,7 +28,7 @@ Analizzerai un set di dati del cambiamento globale medio del livello del mare da
|
||||
Usa i dati per completare le seguenti attività:
|
||||
|
||||
- Usa Pandas per importare i dati da `epa-sea-level.csv`.
|
||||
- Use matplotlib to create a scatter plot using the `Year` column as the x-axis and the `CSIRO Adjusted Sea Level` column as the y-axis.
|
||||
- Usa matplotlib per creare un grafico a dispersione usando la colonna `Year` come asse x e la colonna `CSIRO Adjusted Sea Level` come asse y.
|
||||
- Usa la funzione `linregress` da `scipy.stats` per ottenere la pendenza e l'intercetta y della retta di regressione. Traccia la retta di regressione sopra la parte superiore del grafico a dispersione. Fai passare la linea attraverso l'anno 2050 per prevedere l'aumento del livello del mare nel 2050.
|
||||
- Traccia una nuova retta di regressione utilizzando i dati dall'anno 2000 all'anno più recente nel set di dati. Fai passare la linea anche per l'anno 2050 per prevedere quale sarà l'aumento del livello del mare nel 2050 se il tasso di crescita continuerà come ha fatto dal 2000 in poi.
|
||||
- L'asse x dovrebbe essere `Year`, l'asse y dovrebbe essere `Sea Level (inches)` e il titolo dovrebbe essere `Rise in Sea Level`.
|
||||
|
||||
@@ -10,10 +10,10 @@ dashedName: implement-binary-search
|
||||
|
||||
Binary Search è un algoritmo con efficienza **O(log(n))** che permette di cercare un elemento dentro a un array ordinato. Funziona usando i seguenti step:
|
||||
|
||||
1. Trova il `value` centrale di un array ordinato. If `value == target` return `true` (The value has been found and the search is complete).
|
||||
1. Trova il `value` centrale di un array ordinato. Se `value == target` restituisce `true` (il valore è stato trovato e la ricerca è completa).
|
||||
1. Se invece `value < target`, cerca nella metà destra dell'array nella prossima comparazione.
|
||||
1. Se invece `value > target`, cerca nella metà sinistra dell'array nella prossima comparazione.
|
||||
1. If after searching the whole array the value is not present, return `false` (The array has been searched and the value is not in the array).
|
||||
1. Se dopo aver cercato nell'intero array il valore non è presente, restituisce `false` (l'array è stato setacciato e il valore non è nell'array).
|
||||
|
||||
Come puoi vedere, stai dimessando successivamente un array, cosa che da l'efficienza log(n). Per questa sfida vogliamo vedere il tuo lavoro - come sei arrivato al valore target... la strada che hai preso!
|
||||
|
||||
@@ -21,7 +21,7 @@ Come puoi vedere, stai dimessando successivamente un array, cosa che da l'effici
|
||||
|
||||
Scrivi una funzione `binarySearch` che implementa un algoritmo di ricerca binaria su un array, restituendo il percorso che hai preso (ogni valore centrale di comparazione) per trovare il target nell'array.
|
||||
|
||||
La funzione riceve un array di numeri interi ordinati, e un valore target come input. Restituisce un array contentente in ordine i valori centrali che hai trovato ad ogni dimezzamento dell'array originale fino a che non hai trovato il valore target. Il valore target dovrebbe essere l'ultimo elemento dell'array restituito. If the value is not found, return the string `Value Not Found`.
|
||||
La funzione riceve un array di numeri interi ordinati, e un valore target come input. Restituisce un array contentente in ordine i valori centrali che hai trovato ad ogni dimezzamento dell'array originale fino a che non hai trovato il valore target. Il valore target dovrebbe essere l'ultimo elemento dell'array restituito. Se il valore non è stato trovato, restituisci `Value Not Found`.
|
||||
|
||||
Per esempio, `binarySearch([1,2,3,4,5,6,7], 5)` dovrebbe restituisce `[4,6,5]`.
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ dashedName: step-22
|
||||
|
||||
La spaziatura orizzontale tra elementi di uguale importanza può migliorare la leggibilità del testo.
|
||||
|
||||
Wrap the text `2/3 cup (55g)` in a `span` element.
|
||||
Racchiudi il testo `2/3 cup (55g)` in un elemento `span`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -19,13 +19,13 @@ Dovresti creare un nuovo elemento `span`.
|
||||
assert(document.querySelector('span'));
|
||||
```
|
||||
|
||||
Your `span` element should have the text `2/3 cup (55g)`.
|
||||
L'elemento `span` dovrebbe avere il testo `2/3 cup (55g)`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('span')?.textContent?.trim() === '2/3 cup (55g)');
|
||||
```
|
||||
|
||||
Your `p` element should still have the text `Serving size 2/3 cup (55g)`.
|
||||
L'elemento `p` dovrebbe ancora avere il testo `Serving size 2/3 cup (55g)`.
|
||||
|
||||
```js
|
||||
assert(document.querySelectorAll('p')?.[1]?.innerText === 'Serving size 2/3 cup (55g)');
|
||||
|
||||
@@ -7,17 +7,17 @@ dashedName: step-23
|
||||
|
||||
# --description--
|
||||
|
||||
Now we can add the horizontal spacing using `flex`. In your `p` selector, add a `display` property set to `flex` and a `justify-content` property set to `space-between`.
|
||||
Ora possiamo aggiungere la spaziatura orizzontale usando `flex`. Nel selettore `p`, aggiungi una proprietà `display` impostata su `flex` e una proprietà `justify-content` impostata su `space-between`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `p` selector should have a `display` property set to `flex`.
|
||||
Il selettore `p` dovrebbe avere un proprietà `display` impostata su `flex`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('p')?.display === 'flex');
|
||||
```
|
||||
|
||||
Your `p` selector should have a `justify-content` property set to `space-between`.
|
||||
Il selettore `p` dovrebbe avere una proprietà `justify-content` impostata su `space-between`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('p')?.justifyContent === 'space-between');
|
||||
|
||||
@@ -7,7 +7,7 @@ dashedName: step-26
|
||||
|
||||
# --description--
|
||||
|
||||
Create a new `div` element below your `header` element, and give it a `class` attribute set to `divider large`.
|
||||
Crea un nuovo elemento `div` sotto l'elemento `header` e assegnagli un attributo `class` con il valore `divider large`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -23,7 +23,7 @@ Il nuovo elemento `div` dovrebbe trovarsi dopo l'elemento `header`.
|
||||
assert(document.querySelector('.label')?.lastElementChild?.localName === 'div');
|
||||
```
|
||||
|
||||
Your new `div` element should have the `class` attribute set to `divider large`.
|
||||
Il nuovo elemento `div` dovrebbe avere l'attributo `class` con il valore `divider large`.
|
||||
|
||||
```js
|
||||
const div = document.querySelector('.label')?.lastElementChild;
|
||||
|
||||
@@ -7,29 +7,29 @@ dashedName: step-27
|
||||
|
||||
# --description--
|
||||
|
||||
Create a new `.large` selector and give it a `height` property set to `10px`. Also create an `.large, .medium` selector and set the `background-color` property to `black`.
|
||||
Crea un nuovo selettore `.large` e assegnagli una proprietà `height` con il valore `10px`. Crea anche un selettore `.large, .medium` e imposta la proprietà `background-color` con il valore `black`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have a new `.large` selector.
|
||||
Dovresti avere un nuovo selettore `.large`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.large'));
|
||||
```
|
||||
|
||||
Your `.large` selector should have a `height` property set to `10px`.
|
||||
Il selettore `.large` dovrebbe avere una proprietà `height` con il valore `10px`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.large')?.height === '10px');
|
||||
```
|
||||
|
||||
You should have a new `.large, .medium` selector.
|
||||
Dovresti avere un nuovo selettore `.large, .medium`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.large, .medium'));
|
||||
```
|
||||
|
||||
Your `.large, .medium` selector should have a `background-color` property set to `black`.
|
||||
Il selettore `.large, .medium` dovrebbe avere una proprietà `background-color` con il valore `black`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.large, .medium')?.backgroundColor === 'black');
|
||||
|
||||
@@ -7,7 +7,7 @@ dashedName: step-29
|
||||
|
||||
# --description--
|
||||
|
||||
Create a new `div` below your `.large` element and give it a `class` attribute set to `calories-info`.
|
||||
Crea un nuovo `div` sotto l'elemento `.large` e assegnagli un attributo `class` con il valore `calories-info`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -23,7 +23,7 @@ Il nuovo elemento `div` dovrebbe avere un attributo `class` con il valore `calor
|
||||
assert(document.querySelector('.label')?.lastElementChild?.classList?.contains('calories-info'));
|
||||
```
|
||||
|
||||
Your new `div` should come after the `.large` element.
|
||||
Il nuovo `div` dovrebbe trovarsi dopo l'elemento `.large`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.label')?.lastElementChild?.previousElementSibling?.classList?.contains('large'));
|
||||
|
||||
@@ -9,17 +9,17 @@ dashedName: step-31
|
||||
|
||||
L'unità `rem` sta per `root em` ed è relativa alla dimensione del carattere dell'elemento `html`.
|
||||
|
||||
Create an `.small-text` selector and set the `font-size` to `0.85rem`, which would calculate to be roughly `13.6px` (remember that you set your `html` to have a `font-size` of `16px`).
|
||||
Crea un selettore `.small-text` e imposta la proprietà `font-size` a `0.85rem`, approssimativamente equivalenti a `13.6px` (ricorda che hai dato al tuo `html` una proprietà `font-size` di `16px`).
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have an `.small-text` selector.
|
||||
Dovresti avere un selettore `.small-text`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.small-text'));
|
||||
```
|
||||
|
||||
Your `.small-text` selector should have a `font-size` property set to `0.85rem`.
|
||||
Il selettore `.small-text` dovrebbe avere una proprietà `font-size` con il valore `0.85rem`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.small-text')?.fontSize === '0.85rem');
|
||||
|
||||
@@ -7,35 +7,35 @@ dashedName: step-33
|
||||
|
||||
# --description--
|
||||
|
||||
Below your `.small-text` element, create a new `p` element with the text `Calories`. Also below the `.left-container` element, create a new `span` element with the text `230`.
|
||||
Sotto l'elemento `.small-text`, crea un nuovo elemento `p` con il testo `Calories`. Inoltre, sotto l'elemento `.left-container`, crea un nuovo elemento `span` con il testo `230`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have a new `p` element within your `.calories-info` element.
|
||||
Dovresti avere un nuovo elemento `p` all'interno dell'elemento `.calories-info`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.calories-info')?.querySelector('p'))
|
||||
```
|
||||
|
||||
You should have a new `span` element within your `.calories-info` element.
|
||||
Dovresti avere un nuovo elemento `span` all'interno dell'elemento `.calories-info`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.calories-info')?.querySelector('span'))
|
||||
```
|
||||
|
||||
Your `p` element should come after your `.small-text` element.
|
||||
L'elemento `p` dovrebbe trovarsi dopo l'elemento `.small-text`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.small-text')?.nextElementSibling?.localName === 'p');
|
||||
```
|
||||
|
||||
Your `p` element should have the text `Calories`.
|
||||
L'elemento `p` dovrebbe avere il testo `Calories`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.left-container')?.lastElementChild?.innerText === 'Calories');
|
||||
```
|
||||
|
||||
Your `span` element should come after your `.left-container` element.
|
||||
L'elemento `span` dovrebbe trovarsi dopo l'elemento `.left-container`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.left-container')?.nextElementSibling?.localName ==='span');
|
||||
|
||||
@@ -7,7 +7,7 @@ dashedName: step-36
|
||||
|
||||
# --description--
|
||||
|
||||
Create a `.calories-info span` selector, set its `font-size` to `2.4em` and `font-weight` to `700`.
|
||||
Create un selettore `.calories-info span` e imposta `font-size` su `2.4em` e `font-weight` su `700`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -17,13 +17,13 @@ Dovresti creare un selettore `.calories-info span`.
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.calories-info span'));
|
||||
```
|
||||
|
||||
Your `.calories-info span` selector should have a `font-size` property set to `2.4em`.
|
||||
Il selettore `.calories-info span` dovrebbe avere una proprietà `font-size` con il valore `2.4em`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.calories-info span')?.fontSize === '2.4em');
|
||||
```
|
||||
|
||||
Your `.calories-info span` selector should have a `font-weight` property set to `700`.
|
||||
Il selettore `.calories-info span` dovrebbe avere una proprietà `font-weight` con il valore `700`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.calories-info span')?.fontWeight === '700');
|
||||
|
||||
@@ -9,11 +9,11 @@ dashedName: step-37
|
||||
|
||||
La tipografia è spesso più arte che scienza. Potrebbe essere necessario modificare cose come l'allineamento fino a quando non sembra corretto.
|
||||
|
||||
Give your `.calories-info span` selector a `margin` set to `-7px -2px`. In questo modo, sposterai il testo `230` nella posizione giusta.
|
||||
Assegna al selettore `.calories-info span` una proprietà `margin` con il valore `-7px -2px`. In questo modo, sposterai il testo `230` nella posizione giusta.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your `.calories-info span` selector should have a `margin` set to `-7px -2px`.
|
||||
Il selettore `.calories-info span` dovrebbe avere una proprietà `margin` con il valore `-7px -2px`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.calories-info span')?.margin === '-7px -2px');
|
||||
|
||||
@@ -7,11 +7,11 @@ dashedName: step-40
|
||||
|
||||
# --description--
|
||||
|
||||
Create a new `div` element below your `.medium` element. Give it a `class` attribute set to `daily-value small-text`. Within this new `div`, add a `p` element with the text `% Daily Value *`, and set the `class` attribute to `bold right`.
|
||||
Crea un nuovo elemento `div` sotto l'elemento `.medium`. Assegnagli un attributo `class` impostato su `daily-value small-text`. All'interno di questo nuovo `div`, crea un elemento `p` con il testo `% Daily Value *` e imposta l'attributo `class` con il valore `bold right`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should create a new `div` element after your `.medium` element.
|
||||
Dovresti creare un nuovo elemento `div` dopo l'elemento `.medium`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.label')?.lastElementChild?.localName === 'div');
|
||||
@@ -19,7 +19,7 @@ assert(document.querySelector('.label')?.lastElementChild?.previousElementSiblin
|
||||
assert(document.querySelector('.label')?.lastElementChild?.previousElementSibling?.classList?.contains('medium'));
|
||||
```
|
||||
|
||||
Your new `div` should have a `class` attribute set to `daily-value small-text`.
|
||||
Il nuovo `div` dovrebbe avere un attributo `class` con il valore `daily-value small-text`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.label')?.lastElementChild?.classList?.contains('daily-value'));
|
||||
@@ -38,7 +38,7 @@ Il nuovo elemento `p` dovrebbe avere il testo `% Daily Value *`.
|
||||
assert(document.querySelector('.label')?.lastElementChild?.firstElementChild?.textContent === '% Daily Value *');
|
||||
```
|
||||
|
||||
Your new `p` element should have a `class` attribute set to `bold right`.
|
||||
Il nuovo elemento `p` dovrebbe avere un attributo `class` con il valore `bold right`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.label')?.lastElementChild?.firstElementChild?.classList?.contains('bold'));
|
||||
|
||||
@@ -7,7 +7,7 @@ dashedName: step-43
|
||||
|
||||
# --description--
|
||||
|
||||
Dopo l'ultimo elemento `.divider`, crea un elemento `p` e assegnagli il testo `Total Fat 8g 10%`. Avvolgi `Total Fat` in un elemento `span` con l'attributo `class` con il valore `bold`. Wrap `10%` in another `span` element with the `class` set to `bold`. Also wrap the words `Total Fat 8g` in an additional `span` element for alignment.
|
||||
Dopo l'ultimo elemento `.divider`, crea un elemento `p` e assegnagli il testo `Total Fat 8g 10%`. Avvolgi `Total Fat` in un elemento `span` con l'attributo `class` con il valore `bold`. Racchiudi `10%` in un altro elemento `span` con `class` impostata su `bold`. Inoltre racchiudi il testo `Total Fat 8g` in un elemento `span` aggiuntivo per l'allineamento.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -23,37 +23,37 @@ Il nuovo elemento `p` dovrebbe avere il testo `Total Fat 8g 10%`.
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.innerText?.match(/Total Fat[\s|\n]+8g[\s|\n]+10%/));
|
||||
```
|
||||
|
||||
Your `p` element should have three `span` elements.
|
||||
L'elemento `p` dovrebbe avere tre elementi `span`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelectorAll('span')?.length === 3);
|
||||
```
|
||||
|
||||
One `span` element should wrap the text `Total Fat`.
|
||||
Un elemento `span` dovrebbe racchiudere il testo `Total Fat`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelector('span > span')?.innerText === 'Total Fat');
|
||||
```
|
||||
|
||||
The `span` element around `Total Fat` should have the `class` set to `bold`.
|
||||
L'elemento `span` attorno a `Total Fat` dovrebbe avere l'attributo `class` impostato su `bold`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelector('span > span')?.className === 'bold');
|
||||
```
|
||||
|
||||
A `span` element should wrap the text `10%`.
|
||||
Un elemento `span` dovrebbe racchiudere il testo `10%`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelector('span + span')?.innerText === '10%');
|
||||
```
|
||||
|
||||
The `span` element around `10%` should have the `class` set to `bold`.
|
||||
L'elemento `span` attorno a `10%` dovrebbe avere l'attributo `class` impostato su `bold`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelectorAll('span')?.[1]?.className === 'bold');
|
||||
```
|
||||
|
||||
A `span` element should have the text `Total Fat 8g`.
|
||||
Un elemento `span` dovrebbe avere il testo `Total Fat 8g`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.innerText?.match(/Total Fat[\s|\n]+8g/));
|
||||
|
||||
@@ -13,7 +13,7 @@ Il primo elemento `.no-divider` ha un `.divider` dopo di esso. Crea un altro `.d
|
||||
|
||||
# --hints--
|
||||
|
||||
You should create a new `div` at the end of your `.daily-value` element.
|
||||
Dovresti creare un nuovo `div` alla fine dell'elemento `.daily-value`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.localName === 'div');
|
||||
|
||||
@@ -7,11 +7,11 @@ dashedName: step-54
|
||||
|
||||
# --description--
|
||||
|
||||
Sotto l'ultimo elemento `p`, crea un altro elemento `p` con il testo `Sodium 160mg 7%`. Atorrno al testo `Sodium`, crea un elemento `span` con un attributo `class` impostato su `bold`. Wrap the `7%` text in another `span` element with the `class` set to `bold`. Also add an additional `span` element around `Sodium 160mg` for aligning it correctly.
|
||||
Sotto l'ultimo elemento `p`, crea un altro elemento `p` con il testo `Sodium 160mg 7%`. Atorrno al testo `Sodium`, crea un elemento `span` con un attributo `class` impostato su `bold`. Racchiudi il testo `7%` in un altro elemento `span` con l'attributo `class` impostato su `bold`. Aggiungi anche un altro elemento `span` attorno a `Sodium 160mg` per allinearlo correttamente.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should create a new `p` element at the end of your `.daily-value` element.
|
||||
Dovresti creare un nuovo elemento `p` alla fine dell'elemento `.daily-value`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.localName === 'p');
|
||||
@@ -23,37 +23,37 @@ Il nuovo elemento `p` dovrebbe avere il testo `Sodium 160mg 7%`.
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.innerText?.match(/Sodium[\s|\n]160mg[\s|\n]+7%/));
|
||||
```
|
||||
|
||||
Your new `p` element should have three `span` elements.
|
||||
Il nuovo elemento `p` dovrebbe avere tre elementi `span`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelectorAll('span')?.length === 3);
|
||||
```
|
||||
|
||||
A `span` element should wrap the text `Sodium 360mg`.
|
||||
Un elemento `span` dovrebbe racchiudere il testo `Sodium 360mg`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.firstElementChild?.innerText?.match(/Sodium[\s|\n]160mg/));
|
||||
```
|
||||
|
||||
A `span` element should wrap the text `Sodium`.
|
||||
Un elemento `span` dovrebbe racchiudere il testo `Sodium`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.firstElementChild?.firstElementChild?.innerText === "Sodium");
|
||||
```
|
||||
|
||||
The `span` around `Sodium` should have the `class` attribute set to `bold`.
|
||||
L'elemento `span` attorno a `Sodium` dovrebbe avere l'attributo `class` impostato su `bold`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.firstElementChild?.firstElementChild?.classList?.contains('bold'));
|
||||
```
|
||||
|
||||
A `span` element should wrap the text `7%`.
|
||||
Un elemento `span` dovrebbe racchiudere il testo `7%`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.lastElementChild?.innerText === '7%');
|
||||
```
|
||||
|
||||
The `span` element around `7%` should have the `class` attribute set to `bold`.
|
||||
L'elemento `span` attorno a `7%` dovrebbe avere l'attributo `class` impostato su `bold`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.lastElementChild?.classList?.contains('bold'));
|
||||
|
||||
@@ -7,11 +7,11 @@ dashedName: step-55
|
||||
|
||||
# --description--
|
||||
|
||||
Aggiungi un altro elemento `p` con il testo `Total Carbohydrate 37g 13%`. Like before, use `span` elements to make the text `Total Carbohydrate` and `13%` bold. Also add an additional `span` element to wrap the `Total Carbohydrate 37g` text in a span element so to have it aligned to the left, and `13%` to the right.
|
||||
Aggiungi un altro elemento `p` con il testo `Total Carbohydrate 37g 13%`. Come prima, usa gli elementi `span` per rendere il testo `Total Carbohydrate` e `13%` in grassetto. Aggiungi un altro elemento `span` per racchiudere `Total Carbohydrate 37g`, allineare il testo a sinistra e `13%` a destra.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should create a new `p` element at the end of your `.daily-value` element.
|
||||
Dovresti creare un nuovo elemento `p` alla fine dell'elemento `.daily-value`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.localName === 'p');
|
||||
@@ -23,43 +23,43 @@ Il nuovo elemento `p` dovrebbe avere il testo `Total Carbohydrate 37g 13%`.
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.innerText?.match(/Total Carbohydrate[\s|\n]+37g[\s|\n]+13%/));
|
||||
```
|
||||
|
||||
Your new `p` element should have three `span` elements.
|
||||
Il nuovo elemento `p` dovrebbe avere tre elementi `span`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelectorAll('span')?.length === 3);
|
||||
```
|
||||
|
||||
One `span` element should wrap the text `Total Carbohydrate 37g`.
|
||||
Un elemento `span` dovrebbe racchiudere il testo `Total Carbohydrate 37g`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.firstElementChild?.innerText?.match(/Total Carbohydrate[\s|\n]+37g/));
|
||||
```
|
||||
|
||||
One `span` element should wrap the text `Total Carbohydrate`.
|
||||
Un elemento `span` dovrebbe racchiudere il testo `Total Carbohydrate`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.firstElementChild?.firstElementChild?.innerText === 'Total Carbohydrate');
|
||||
```
|
||||
|
||||
The `span` element around `Total Carbohydrate` should have the `class` attribute set to `bold`.
|
||||
L'elemento `span` attorno a `Total Carbohydrate` dovrebbe avere l'attributo `class` impostato su `bold`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.firstElementChild?.firstElementChild?.classList?.contains('bold'));
|
||||
```
|
||||
|
||||
A `span` element should wrap the text `13%`.
|
||||
Un elemento `span` dovrebbe racchiudere il testo `13%`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.lastElementChild?.innerText === '13%');
|
||||
```
|
||||
|
||||
The `span` element around `13%` should have the `class` attribute set to `bold`.
|
||||
L'elemento `span` attorno a `13%` dovrebbe avere l'attributo `class` impostato su `bold`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.lastElementChild?.classList?.contains('bold'));
|
||||
```
|
||||
|
||||
Your second `span` element should wrap the text `13%`.
|
||||
Il secondo elemento `span` dovrebbe racchiudere il testo `13%`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.lastElementChild?.innerText === '13%');
|
||||
|
||||
@@ -11,7 +11,7 @@ Crea un altro elemento `p` dopo l'ultimo `.divider` e dagli il testo `Total Suga
|
||||
|
||||
# --hints--
|
||||
|
||||
You should create a new `p` and `div` element at the end of your `.daily-value` element.
|
||||
Dovresti creare un nuovo elemento `p` e un nuovo `div` alla fine dell'elemento `.daily-value`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.localName === 'p');
|
||||
|
||||
@@ -7,17 +7,17 @@ dashedName: step-59
|
||||
|
||||
# --description--
|
||||
|
||||
Create a `.double-indent` selector and give it a left margin of `2em`.
|
||||
Crea un selettore `.double-indent` e dagli un margine sinistro di `2em`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have a new `.double-indent` selector.
|
||||
Dovresti avere un nuovo selettore `.double-indent`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.double-indent'));
|
||||
```
|
||||
|
||||
Your `.double-indent` selector should have a `margin-left` property set to `2em`.
|
||||
Il selettore `.double-indent` dovrebbe avere una proprietà `margin-left` con il valore `2em`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.double-indent')?.marginLeft === '2em');
|
||||
|
||||
@@ -9,29 +9,29 @@ dashedName: step-62
|
||||
|
||||
Crea un altro elemento `p` sotto il divider grande. Dai all'elemento `p` il testo `Vitamin D 2mcg 10%`.
|
||||
|
||||
The `p` element contains only text, you can wrap the percentage in a `span` element so that it is considered a separate entity from the rest of the text, and it's moved to the right.
|
||||
L'elemento `p` contiene solo testo, puoi racchiudere la percentuale in un elemento `span` in modo che sia considerato un'entità separata dal resto del testo e venga spostato a destra.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should create a new `p` element at the end of your `.daily-value` element.
|
||||
Dovresti creare un nuovo elemento `p` alla fine dell'elemento `.daily-value`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.localName === 'p');
|
||||
```
|
||||
|
||||
Your new `p` element should have the text `Vitamin D 2mcg 10%`.
|
||||
Il nuovo elemento `p` dovrebbe avere il testo `Vitamin D 2mcg 10%`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.innerText?.match(/Vitamin D 2mcg[\s|\n]+10%/));
|
||||
```
|
||||
|
||||
Your new `p` element should have a `span` element.
|
||||
Il nuovo elemento `p` dovrebbe avere un elemento `span`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelectorAll('span')?.length === 1);
|
||||
```
|
||||
|
||||
Your `span` element should not be bold.
|
||||
L'elemento `span` non dovrebbe essere in grassetto.
|
||||
|
||||
```js
|
||||
assert(!document.querySelector('.daily-value.small-text')?.lastElementChild?.querySelector('span')?.classList?.contains('bold'));
|
||||
|
||||
@@ -11,7 +11,7 @@ Crea un altro elemento `p` e dagli il testo `Calcium 260mg 20%`. Allinea il `20%
|
||||
|
||||
# --hints--
|
||||
|
||||
You should create two new `p` elements at the end of your `.daily-value` element.
|
||||
Dovresti creare due nuovi elementi `p` alla fine dell'elemento `.daily-value`.
|
||||
|
||||
```js
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.localName === 'p');
|
||||
@@ -30,7 +30,7 @@ Il primo nuovo elemento `p` dovrebbe avere un elemento `span`.
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.localName === 'span');
|
||||
```
|
||||
|
||||
Your first `span` element not be bold.
|
||||
Your first `span` element should not be bold.
|
||||
|
||||
```js
|
||||
assert(!document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.classList?.contains('bold'));
|
||||
@@ -54,7 +54,7 @@ Il secondo nuovo elemento `p` dovrebbe avere un elemento `span`.
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.firstElementChild?.localName === 'span');
|
||||
```
|
||||
|
||||
Your second `span` element should not be bold.
|
||||
Il secondo elemento `span` non dovrebbe essere in grassetto.
|
||||
|
||||
```js
|
||||
assert(!document.querySelector('.daily-value.small-text')?.lastElementChild?.firstElementChild?.classList?.contains('bold'));
|
||||
|
||||
@@ -7,11 +7,11 @@ dashedName: step-41
|
||||
|
||||
# --description--
|
||||
|
||||
The text `* Daily Value %` should be aligned to the right. Create a `.right` selector and use the `justify-content` property to do it.
|
||||
Il testo `* Daily Value %` dovrebbe essere allineato a destra. Crea un selettore `.right` e usa la proprietà `justify-content` per farlo.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have a `.right` selector.
|
||||
Dovresti avere un selettore `.right`.
|
||||
|
||||
```js
|
||||
const hasRight = new __helpers.CSSHelp(document).getStyle('.right');
|
||||
@@ -19,7 +19,7 @@ assert(hasRight);
|
||||
|
||||
```
|
||||
|
||||
The `.right` selector should have the `justify-content` property set to `flex-end`.
|
||||
Il selettore `.right` dovrebbe avere la proprietà `justify-content` impostata su `flex-end`.
|
||||
|
||||
```js
|
||||
const rightJustifyContent = new __helpers.CSSHelp(document).getStyle('.right')?.getPropertyValue('justify-content');
|
||||
|
||||
@@ -7,17 +7,17 @@ dashedName: step-32
|
||||
|
||||
# --description--
|
||||
|
||||
Create a `.calories-info h2` selector and remove all margins.
|
||||
Crea un selettore `.calories-info h2` e rimuovi tutti i margini.
|
||||
|
||||
# --hints--
|
||||
|
||||
Create a `.calories-info h2` selector.
|
||||
Crea un selettore `.calories-info h2`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.calories-info h2'));
|
||||
```
|
||||
|
||||
Your `.calories-info h2` selector should have a `margin` set to `0`.
|
||||
Il selettore `.calories-info h2` dovrebbe avere una proprietà `margin` con il valore `0`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.calories-info h2')?.margin === '0px');
|
||||
|
||||
@@ -7,29 +7,29 @@ dashedName: step-34
|
||||
|
||||
# --description--
|
||||
|
||||
Create a new `.calories-info` selector and give it a `display` property set to `flex`. Also give it a `justify-content` property set to `space-between` and `align-items` property set to `flex-end`.
|
||||
Crea un nuovo selettore `.calories-info` e assegnagli una proprietà `display` con il valore `flex`. Dagli anche una proprietà `justify-content` impostata su `space-between` e una proprietà `align-items` impostata su `flex-end`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should create a `.calories-info` selector.
|
||||
Dovresti creare un selettore `.calories-info`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.calories-info'));
|
||||
```
|
||||
|
||||
Your `.calories-info` selector should have a `display` property set to `flex`.
|
||||
Il selettore `.calories-info` dovrebbe avere una proprietà `display` con il valore `flex`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.calories-info')?.display === 'flex');
|
||||
```
|
||||
|
||||
Your `.calories-info` selector should have a `justify-content` property set to `space-between`.
|
||||
Il selettore `.calories-info` dovrebbe avere una proprietà `justify-content` con il valore `space-between`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.calories-info')?.justifyContent === 'space-between');
|
||||
```
|
||||
|
||||
Your `.calories-info` selector should have a `align-items` property set to `flex-end`.
|
||||
Il selettore `.calories-info` dovrebbe avere una proprietà `align-items` impostata su `flex-end`.
|
||||
|
||||
```js
|
||||
assert(new __helpers.CSSHelp(document).getStyle('.calories-info')?.alignItems === 'flex-end');
|
||||
|
||||
@@ -7,7 +7,7 @@ dashedName: step-62
|
||||
|
||||
# --description--
|
||||
|
||||
The `locations` array contains two locations: the `town square` and the `store`. Currently you are passing that entire array into the `update` function. Passa soltanto il primo elemento dell'array `locations` aggiungendo `[0]` alla fine della variabile. Ad esempio: `myFunction(arg[0]);`.
|
||||
L'array `locations` contiene due location: `town square` e `store`. Attualmente stai passando l'intero array nella funzione `update`. Passa soltanto il primo elemento dell'array `locations` aggiungendo `[0]` alla fine della variabile. Ad esempio: `myFunction(arg[0]);`.
|
||||
|
||||
Questa notazione si chiama <dfn>notazione a parentesi</dfn>. I valori in un array sono accessibili tramite il loro indice. Gli indici sono valori numerici e partono da 0 - questo sistema è detto a base zero. `arg[0]` è il primo elemento nell'array `arg`.
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.prev
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.localName === 'span');
|
||||
```
|
||||
|
||||
Your first `span` element not be bold.
|
||||
Your first `span` element should not be bold.
|
||||
|
||||
```js
|
||||
assert(!document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.classList?.contains('bold'));
|
||||
|
||||
@@ -28,7 +28,7 @@ Você analisará um dataset da mudança média do nível do mar global desde 188
|
||||
Use os dados para completar as seguintes tarefas:
|
||||
|
||||
- Use o Pandas para importar os dados de `epa-sea-level.csv`.
|
||||
- Use matplotlib to create a scatter plot using the `Year` column as the x-axis and the `CSIRO Adjusted Sea Level` column as the y-axis.
|
||||
- Use a matplotlib para criar um diagrama de dispersão usando a coluna `Year` como eixo x e a coluna `CSIRO Adjusted Sea Level` (Nível do mar ajustado) como o eixo y.
|
||||
- Use a função `linregress` do `scipy.stats` para obter o coeficiente angular e o ponto de interceptação da linha de y do melhor ajuste. Trace a linha de melhor ajuste na parte superior do diagrama de dispersão. Faça a linha passar pelo ano 2050 para prever o aumento do nível do mar em 2050.
|
||||
- Trace uma nova linha do melhor ajuste utilizando apenas os dados do ano 2000 ao longo do último ano no dataset. Faça com que a linha passe também pelo ano 2050 para prever o aumento do nível do mar em 2050 se a taxa de crescimento continuar como está desde o ano 2000.
|
||||
- O rótulo de x deve ser `Year` e o rótulo de y deve ser `Sea Level (inches)` (Nível do mar, em polegadas), e o título deve ser `Rise in Sea Level` (Aumento do nível do mar).
|
||||
|
||||
@@ -10,10 +10,10 @@ dashedName: implement-binary-search
|
||||
|
||||
A busca binária é um algoritmo de eficiência **O(log(n))** para procurar um elemento em um array ordenado. Ele opera usando as seguintes etapas:
|
||||
|
||||
1. Encontrar o `value` do meio de um array ordenado. If `value == target` return `true` (The value has been found and the search is complete).
|
||||
1. Encontrar o `value` do meio de um array ordenado. Se `value == target` retornou `true` (O valor foi encontrado e a pesquisa está completa).
|
||||
1. Se `value < target`, procurar à direita do meio do array na próxima comparação.
|
||||
1. Se `value > target`, procurar à esquerda do meio do array na próxima comparação.
|
||||
1. If after searching the whole array the value is not present, return `false` (The array has been searched and the value is not in the array).
|
||||
1. Se, depois de pesquisar no array inteiro, o valor não está presente, retorne `false` (O array foi pesquisado e o valor não está no array).
|
||||
|
||||
Como você pode ver, você está dividindo um array para metade com sucesso, o que traz a eficiência log(n). Para este desafio, queremos que você mostre seu trabalho - como você conseguiu o valor de destino... o caminho que você fez!
|
||||
|
||||
@@ -21,7 +21,7 @@ Como você pode ver, você está dividindo um array para metade com sucesso, o q
|
||||
|
||||
Escreva uma função `binarySearch` que implemente o algoritmo de busca binária em um array, retornando o caminho que você utilizou (cada comparação com o valor do meio) para encontrar o destino em um array.
|
||||
|
||||
A função recebe um array ordenado de números inteiros e um valor de destino como entrada. Ele retorna um array contendo (em ordem) o valor do meio que você encontrou a cada divisão do array original até encontrar o valor de destino. O valor de destino deve ser o último elemento do array retornado. If the value is not found, return the string `Value Not Found`.
|
||||
A função recebe um array ordenado de números inteiros e um valor de destino como entrada. Ele retorna um array contendo (em ordem) o valor do meio que você encontrou a cada divisão do array original até encontrar o valor de destino. O valor de destino deve ser o último elemento do array retornado. Se o valor não for encontrado, retorne a string `Value Not Found`.
|
||||
|
||||
Por exemplo, `binarySearch([1,2,3,4,5,6,7], 5)` retornará `[4,6,5]`.
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ dashedName: step-55
|
||||
|
||||
# --description--
|
||||
|
||||
Adicione outro elemento `p` com o texto `Total Carbohydrate 37g 13%`. Like before, use `span` elements to make the text `Total Carbohydrate` and `13%` bold. Adicione também um elemento `span` para envolver o texto `Total Carbohydrate 37g` em um elemento span que ele esteja alinhado à esquerda e `13%` à direita.
|
||||
Adicione outro elemento `p` com o texto `Total Carbohydrate 37g 13%`. Como antes, use elementos `span` para deixar o texto `Total Carbohydrate` e o texto `13%` em negrito. Adicione também um elemento `span` para envolver o texto `Total Carbohydrate 37g` em um elemento span que ele esteja alinhado à esquerda e `13%` à direita.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ O primeiro novo elemento `p` deve ter um elemento `span`.
|
||||
assert(document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.localName === 'span');
|
||||
```
|
||||
|
||||
O primeiro elemento `span` não deve estar em negrito.
|
||||
Your first `span` element should not be bold.
|
||||
|
||||
```js
|
||||
assert(!document.querySelector('.daily-value.small-text')?.lastElementChild?.previousElementSibling?.firstElementChild?.classList?.contains('bold'));
|
||||
|
||||
@@ -7,7 +7,7 @@ dashedName: step-62
|
||||
|
||||
# --description--
|
||||
|
||||
The `locations` array contains two locations: the `town square` and the `store`. Currently you are passing that entire array into the `update` function. Passe apenas o primeiro elemento do array `locations` adicionando `[0]` no final da variável. Por exemplo: `myFunction(arg[0]);`.
|
||||
O array `locations` contém dois locais: a praça da cidade (em inglês, `town square`) e a loja (em inglês, `store`). No momento, você está passando esse array inteiro para a função de `update`. Passe apenas o primeiro elemento do array `locations` adicionando `[0]` no final da variável. Por exemplo: `myFunction(arg[0]);`.
|
||||
|
||||
Isso é chamado de <dfn>notação de colchete</dfn>. Valores em um array são acessados pelo índice. Índices são valores numéricos e começam em 0 – isto é chamado de indexação baseada em zero. `arg[0]` deve ser o primeiro elemento no array `arg`.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b87367417b2b2512b41
|
||||
title: Оголосіть змінну, доступну лише для читання, з ключовим словом Const
|
||||
title: Оголошення змінної для читання з ключовим словом const
|
||||
challengeType: 1
|
||||
forumTopicId: 301201
|
||||
dashedName: declare-a-read-only-variable-with-the-const-keyword
|
||||
@@ -10,57 +10,57 @@ dashedName: declare-a-read-only-variable-with-the-const-keyword
|
||||
|
||||
Ключове слово `let` є не єдиним новим способом оголосити змінну. В ES6 можливо також оголосити змінні, використовуючи ключове слово `const`.
|
||||
|
||||
У `const` є ті ж круті функції, що й в `let` з приємним бонусом — тепер змінні, оголошені за допомогою `const`, доступні лише для читання. Вони мають константне значення. Тобто, як тільки змінна стає призначеною `const`, її вже неможливо призначити знову:
|
||||
`const` має ті ж круті функції, що й `let`, але з бонусом: тепер змінні, оголошені за допомогою `const`, доступні лише для читання. Вони мають константне значення, тобто після присвоєння змінної з `const`, її неможливо присвоїти знову:
|
||||
|
||||
```js
|
||||
const FAV_PET = "Cats";
|
||||
FAV_PET = "Dogs";
|
||||
```
|
||||
|
||||
Консоль показуватиме помилку через перепризначення значення `FAV_PET`.
|
||||
Консоль показуватиме помилку через повторне присвоєння значення `FAV_PET`.
|
||||
|
||||
Змінні, які не передбачають перепризначення, слід називати, використовуючи ключове слово `const`. Це може знадобитися, якщо ви випадково спробуєте перепризначити змінну, яка повинна бути константною.
|
||||
Змінні, які не передбачають повторного присвоєння, потрібно називати, використовуючи ключове слово `const`. Це може знадобитися, якщо ви випадково спробуєте повторно присвоїти змінну, яка повинна залишатись константною.
|
||||
|
||||
**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--
|
||||
|
||||
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.
|
||||
Змініть код так, щоб усі змінні були оголошені за допомогою `let` або `const`. Використайте `let` для змінних значень, а `const` для незмінних значень. Крім того, перейменуйте змінні, оголошені за допомогою `const`, щоб відповідати загальним практикам. Не змінюйте рядки, які присвоєні змінним.
|
||||
|
||||
# --hints--
|
||||
|
||||
`var` should not exist in your code.
|
||||
`var` повинне бути відсутнім у коді.
|
||||
|
||||
```js
|
||||
assert.notMatch(code, /var/g);
|
||||
```
|
||||
|
||||
You should change `fCC` to all uppercase.
|
||||
Ви повинні змінити `fCC` на верхній регістр.
|
||||
|
||||
```js
|
||||
assert.match(code, /(FCC)/);
|
||||
assert.notMatch(code, /(fCC)/);
|
||||
```
|
||||
|
||||
`FCC` should be a constant variable declared with `const`.
|
||||
`FCC` повинна бути константною змінною, оголошеною з `const`.
|
||||
|
||||
```js
|
||||
assert.match(code, /const\s+FCC/);
|
||||
```
|
||||
|
||||
The string assigned to `FCC` should not be changed.
|
||||
Не потрібно змінювати рядок, присвоєний до `FCC`.
|
||||
|
||||
```js
|
||||
assert.equal(FCC, 'freeCodeCamp');
|
||||
```
|
||||
|
||||
`fact` should be declared with `let`.
|
||||
`fact` повинна бути оголошеною із `let`.
|
||||
|
||||
```js
|
||||
assert.match(code, /(let\s+fact)/g);
|
||||
```
|
||||
|
||||
`console.log` should be changed to print the `FCC` and `fact` variables.
|
||||
`console.log` потрібно змінити так, щоб виводились змінні `FCC` та `fact`.
|
||||
|
||||
```js
|
||||
assert.match(code, /console\.log\(\s*FCC\s*\,\s*fact\s*\)\s*;?/g);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b5
|
||||
title: Уникнення літературних цитат в рядках
|
||||
title: Порятунок цитат у рядках
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c2QvgSr'
|
||||
forumTopicId: 17568
|
||||
@@ -9,15 +9,15 @@ dashedName: escaping-literal-quotes-in-strings
|
||||
|
||||
# --description--
|
||||
|
||||
Коли ви зазначаєте рядок, вам потрібно починати і закінчувати його одинарними або подвійними лапками. Що стається, коли ви потребуєте літературну цитату `"` or `'` всередині вашого рядка?
|
||||
Коли ви визначаєте рядок, він повинен починатися та закінчуватися одинарними або подвійними лапками. Що робити, якщо всередині рядка потрібно написати цитату в `"` чи `'`?
|
||||
|
||||
В JavaScript, ви можете <dfn>вийти</dfn> з цитати і розглядати її як кінець рядка лапки, розмістивши <dfn>зворотнього слешу</dfn> (`\`) перед лапкою.
|
||||
У JavaScript можна <dfn>уникнути</dfn> непотрібного завершення рядка, написавши <dfn>зворотну косу риску</dfn> (`\`) на початку цитати.
|
||||
|
||||
```js
|
||||
const sampleStr = "Alan said, \"Peter is learning JavaScript\".";
|
||||
```
|
||||
|
||||
Це сигнали для JavaScript про те, що така цитата не є кінцевим рядком, а повинна з'явитися всередині рядка. Тому якщо ви введете це в консолі, то отримаєте:
|
||||
Це повідомляє JavaScript про те, що цитата не є кінцем рядка, а повинна з’явитися всередині рядка. Якщо ви надрукуєте це на консолі, то отримаєте:
|
||||
|
||||
```js
|
||||
Alan said, "Peter is learning JavaScript".
|
||||
@@ -25,7 +25,7 @@ Alan said, "Peter is learning JavaScript".
|
||||
|
||||
# --instructions--
|
||||
|
||||
Використовуйте <dfn>косі риски</dfn> щоб зазначити для рядка змінну `myStr`, і таким чином ввівши її на консолі, побачите:
|
||||
Використайте <dfn>зворотні косі риски</dfn>, щоб присвоїти рядок до змінної `myStr` та при виводі на консоль ви бачили наступне:
|
||||
|
||||
```js
|
||||
I am a "double quoted" string inside "double quotes".
|
||||
@@ -33,13 +33,13 @@ I am a "double quoted" string inside "double quotes".
|
||||
|
||||
# --hints--
|
||||
|
||||
Вам слід використовувати дві подвійні лапки (`"`) і чотири подвійні лапки (`\"`).
|
||||
Ви повинні використати дві подвійні лапки (`"`) та чотири екрановані подвійні лапки (`\"`).
|
||||
|
||||
```js
|
||||
assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2);
|
||||
```
|
||||
|
||||
Variable `myStr` should contain the string: `I am a "double quoted" string inside "double quotes".`
|
||||
Змінна `myStr` повинна містити рядок `I am a "double quoted" string inside "double quotes".`
|
||||
|
||||
```js
|
||||
assert(/I am a "double quoted" string inside "double quotes(\."|"\.)$/.test(myStr));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244db
|
||||
title: Вступ до інструкцій «else if»
|
||||
title: Вступ до інструкцій else if
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/caeJ2hm'
|
||||
forumTopicId: 18206
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244da
|
||||
title: Вступ до інструкцій «else»
|
||||
title: Вступ до інструкцій else
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cek4Efq'
|
||||
forumTopicId: 18207
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5675e877dbd60be8ad28edc6
|
||||
title: Ітерація через масив за допомогою циклу For
|
||||
title: Ітерація масиву за допомогою циклу for
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/caeR3HB'
|
||||
forumTopicId: 18216
|
||||
@@ -9,7 +9,7 @@ dashedName: iterate-through-an-array-with-a-for-loop
|
||||
|
||||
# --description--
|
||||
|
||||
Ітерація через вміст масиву є поширеною задачею у JavaScript. Це можна робити за допомогою циклу `for`. Цей код буде виводити кожен елемент масиву `arr` на консоль:
|
||||
У JavaScript часто доводиться перебрати вміст масиву. Це можна зробити за допомогою циклу `for`. Цей код виводитиме кожен елемент масиву `arr` на консоль:
|
||||
|
||||
```js
|
||||
const arr = [10, 9, 8, 7, 6];
|
||||
@@ -19,11 +19,11 @@ for (let i = 0; i < arr.length; i++) {
|
||||
}
|
||||
```
|
||||
|
||||
Пам'ятайте, що масиви мають індексацію, яка рахується від нуля і це означає, що останній індекс масиву - це `length - 1`. Нашою умовою для цього циклу є `i < arr.length`, який зупиняє цикл, коли `i` дорівнює `length`. У цьому випадку останньою ітерацією є `i === 4`, тобто коли `i` дорівнює `arr.length - 1` і виводить `6` на консоль. Тоді `i` збільшується на `5`, і цикл закінчується тому, що код `i < arr.length` є `false`.
|
||||
Пам'ятайте, що масиви мають індексацію на основі нуля і це означає, що останнім індексом масиву є `length - 1`. Нашою умовою для цього циклу є `i < arr.length`, який зупиняє цикл, коли `i` дорівнює `length`. У цьому випадку останньою ітерацією є `i === 4`, тобто коли `i` дорівнює `arr.length - 1` і виводить `6` на консоль. Тоді `i` збільшується до `5`, і цикл закінчується через те, що `i < arr.length` є `false`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Оголосіть та ініціалізуйте змінну `total` до `0`. Використовуйте цикл `for` для додавання значення кожного елементу масиву `myArr` до `total`.
|
||||
Оголосіть та ініціалізуйте змінну `total` до `0`. Використайте цикл `for`, щоб додати значення кожного елемента масиву `myArr` до `total`.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -39,13 +39,13 @@ assert(code.match(/(var|let|const)\s*?total\s*=\s*0.*?;?/));
|
||||
assert(total === 20);
|
||||
```
|
||||
|
||||
Слід використовувати цикл `for` для ітерації через `myArr`.
|
||||
Ви повинні використати цикл `for`, щоб перебрати `myArr`.
|
||||
|
||||
```js
|
||||
assert(/for\s*\(/g.test(code) && /myArr\s*\[/g.test(code));
|
||||
```
|
||||
|
||||
Не потрібно намагатися напряму призначити `total` значення 20.
|
||||
Не потрібно намагатися напряму присвоїти значення 20 до `total`.
|
||||
|
||||
```js
|
||||
assert(!__helpers.removeWhiteSpace(code).match(/total[=+-]0*[1-9]+/gm));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5a2efd662fb457916e1fe604
|
||||
title: Ітерація з "do...while" циклами, JavaScript
|
||||
title: Ітерація з циклами do...while у JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cDqWGcp'
|
||||
forumTopicId: 301172
|
||||
@@ -9,7 +9,7 @@ dashedName: iterate-with-javascript-do---while-loops
|
||||
|
||||
# --description--
|
||||
|
||||
Наступний вид циклів, який ви вивчите, називається `do...while` циклом. Він називається `do...while` циклом, тому що, спочатку, не зважаючи ні на що, він `do` (робить) одну передачу коду, а потім продовжує виконувати цикл `while` поки вказана умова обчислюється до `true`.
|
||||
Наступним ви вивчите цикл `do...while`. Цикл `do...while` називається так, бо спочатку він щось виконує у коді (`do`), а потім продовжує цикл (`while`), доки умова не становитиме `true`.
|
||||
|
||||
```js
|
||||
const ourArray = [];
|
||||
@@ -21,7 +21,7 @@ do {
|
||||
} 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`:
|
||||
Наведений вище приклад поводиться подібно до інших типів циклів, і кінцевий масив матиме такий вигляд: `[0, 1, 2, 3, 4]`. Однак цикл `do...while` відрізняється від інших циклів своєю поведінкою, коли умова не відповідає першій перевірці. Розглянемо на дії. Ось звичайний цикл `while`, який запускає код за умови, що `i < 5`:
|
||||
|
||||
```js
|
||||
const ourArray = [];
|
||||
@@ -33,7 +33,7 @@ while (i < 5) {
|
||||
}
|
||||
```
|
||||
|
||||
У цьому прикладі ми ініціалізуємо значення `ourArray` до порожнього масиву і значення `i` до 5. Коли ми виконуємо `while` цикл, умова обчислюється до `false`, тому що `i` не менше ніж 5, таким чином ми не виконуємо код всередині циклу. Результатом є те, що до `ourArray` не буде додано ніяких значень і він все ще виглядатиме, як `[]`, коли всі коди, в наведеному вище прикладі, вже завершили роботу. А зараз погляньте на `do...while` цикл:
|
||||
У цьому прикладі ми ініціалізуємо значення `ourArray` до порожнього масиву і значення `i` до 5. Коли ми виконуємо цикл `while`, умова обчислюється як `false`, оскільки `i` не менше за 5, тому ми не виконуємо код всередині циклу. Результатом є те, що `ourArray` не матиме доданих значень і досі виглядатиме як `[]`, коли весь код у прикладі вище вже завершить виконання. А зараз погляньте на цикл `do...while`:
|
||||
|
||||
```js
|
||||
const ourArray = [];
|
||||
@@ -45,11 +45,11 @@ do {
|
||||
} while (i < 5);
|
||||
```
|
||||
|
||||
У цьому випадку, ми ініціалізуємо значення `i` до 5, так само, як ми зробили з `while` циклом. Коли ми доходимо до наступного рядка, то бачимо, що умови для обчислення немає. Таким чином, ми рухаємось до коду, що знаходиться у фігурних дужках, і виконуємо його. Ми додамо єдиний елемент до масиву, а потім збільшимо `i` перед тим, як перейти до перевірки умови. Коли ми нарешті обчислимо умову `i < 5` в останньому рядку, ми побачимо, що зараз `i` становить 6, що провалює перевірку умови. Тому, ми виходимо з циклу і завершуємо роботу. Наприкінці наведеного вище прикладу, значення `ourArray` становить `[5]`. В цілому, `do...while` цикл гарантує те, що код всередині циклу буде виконуватися принаймні один раз. Давайте спробуємо підготувати `do...while` цикл до роботи, висуваючи значення до масиву.
|
||||
У цьому випадку ми ініціалізуємо значення `i` до 5, так само, як ми зробили з циклом `while`. Коли ми доходимо до наступного рядка, то бачимо, що немає умови, тому ми переходимо до коду у фігурних дужках та виконуємо його. Ми додамо один елемент до масиву та збільшимо `i` перед тим, як перейти до перевірки умови. Коли ми обчислимо умову `i < 5` в останньому рядку, ми побачимо, що зараз `i` дорівнює 6 та не проходить перевірку умови, тому ми виходимо з циклу і завершуємо роботу. В кінці вищеподаного прикладу, значення `ourArray` становить `[5]`. По суті, цикл `do...while` гарантує те, що код всередині циклу виконається принаймні один раз. Спробуємо заставити цикл `do...while` працювати, передаючи значення до масиву.
|
||||
|
||||
# --instructions--
|
||||
|
||||
В коді змініть `while` цикл на `do...while` цикл і він висуватиме лише число `10` до `myArray`, а `i` буде дорівнювати `11`, коли код закінчить роботу.
|
||||
Змініть цикл `while` у коді на цикл `do...while` так, щоб цикл передавав лише число `10` до `myArray`, та `i` дорівнювала `11`, коли код закінчить виконання.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -65,7 +65,7 @@ assert(code.match(/do/g));
|
||||
assert.deepEqual(myArray, [10]);
|
||||
```
|
||||
|
||||
`i` повинне дорівнювати `11`
|
||||
`i` повинна дорівнювати `11`
|
||||
|
||||
```js
|
||||
assert.equal(i, 11);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb5bdef
|
||||
title: Ітерація для циклів з JavaScript
|
||||
title: Ітерація з циклами for у JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c9yNVCe'
|
||||
forumTopicId: 18219
|
||||
@@ -9,21 +9,21 @@ dashedName: iterate-with-javascript-for-loops
|
||||
|
||||
# --description--
|
||||
|
||||
Ви можете виконати один і той самий код декілька разів, використовуючи цикл.
|
||||
Ви можете виконати один і той самий код декілька разів за допомогою циклу.
|
||||
|
||||
Найбільш поширеним типом JavaScript циклу є `for` цикл, тому що він виконується протягом певної кількості разів.
|
||||
Найпоширенішим типом циклу в JavaScript є `for`, оскільки він виконується певну кількість разів.
|
||||
|
||||
For-цикли визнано трьома додатковими виразами, які розділені крапкою з комою:
|
||||
Цикли for оголошуються з трьома додатковими виразами, які розділені крапкою з комою:
|
||||
|
||||
`for (a; b; c)`, де `a` — це твердження ініціалізації, `b` — твердження умови, а `c` — остаточний вираз.
|
||||
`for (a; b; c)`, де `a` є інструкцією ініціалізації, `b` є інструкцією умови, а `c` є кінцевим виразом.
|
||||
|
||||
Твердження ініціалізації виконується лише один раз, перед початком циклу. Воно переважно використовується для визначення і налаштування змінної циклу.
|
||||
Інструкція ініціалізації виконується лише один раз (перед початком циклу). Її переважно використовують, щоб визначити та налаштувати змінну циклу.
|
||||
|
||||
Твердження умови обчислюється на початку кожної ітерації циклу і продовжуватиметься до тих пір, поки не обчислиться до `true`. Коли, на початку ітерації, умова становить `false`, цикл припинить виконуватись. Це означає те, що якщо умова починається як "false", ваш цикл ніколи не виконається.
|
||||
Інструкція умови обчислюється на початку кожної ітерації циклу і продовжуватиметься до тих пір, поки не обчислиться до `true`. Коли на початку ітерації умова становить `false`, цикл припинить виконуватись. Це означає те, що якщо умова починається як «false», ваш цикл ніколи не виконається.
|
||||
|
||||
Остаточний вираз виконується наприкінці кожної ітерації циклу, перед перевіркою наступної умови і, зазвичай, використовується для того, щоб збільшити або зменшити лічильник циклу.
|
||||
Кінцевий вираз виконується в кінці кожної ітерації циклу, перед перевіркою наступної умови і, зазвичай, використовується для того, щоб збільшити або зменшити лічильник.
|
||||
|
||||
У наступному прикладі ми ініціалізуємо та ітеруємо `i = 0` допоки наша умова `i < 5` не буде правильною. Ми збільшимо `i` на `1` у кожній ітерації циклу `i++` у ролі нашого остаточного виразу.
|
||||
У наступному прикладі ми ініціалізуємо з `i = 0` та ітеруємо, доки наша умова `i < 5` не буде істинною. Ми збільшимо `i` на `1` у кожній ітерації циклу з кінцевим виразом `i++`.
|
||||
|
||||
```js
|
||||
const ourArray = [];
|
||||
@@ -33,11 +33,11 @@ for (let i = 0; i < 5; i++) {
|
||||
}
|
||||
```
|
||||
|
||||
`ourArray` тепер матиме значення `[0, 1, 2, 3, 4]`.
|
||||
Тепер `ourArray` матиме значення `[0, 1, 2, 3, 4]`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Використовуйте `for` цикл для того, щоб перемістити значення 1 через 5 на `myArray`.
|
||||
Використайте цикл `for`, щоб передати значення від 1 до 5 до `myArray`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb1bdef
|
||||
title: Ітерація циклів JavaScript
|
||||
title: Ітерація з циклами while у JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c8QbnCM'
|
||||
forumTopicId: 18220
|
||||
@@ -9,7 +9,7 @@ dashedName: iterate-with-javascript-while-loops
|
||||
|
||||
# --description--
|
||||
|
||||
Завдяки циклу, Ви можете запустити той самий код декілька разів.
|
||||
Ви можете виконати один і той самий код декілька разів за допомогою циклу.
|
||||
|
||||
Перший тип циклу, який ми вивчатимемо, називається `while`, оскільки виконується за заданою істинною умовою і припиняється, як тільки ця умова більше не буде істинною.
|
||||
|
||||
@@ -23,9 +23,9 @@ while (i < 5) {
|
||||
}
|
||||
```
|
||||
|
||||
У прикладі вище коду цикл `while` виконуватиметься 5 разів і додаватиме числа від 0 до 4 до `ourArray`.
|
||||
У вищеподаному прикладі цикл `while` виконуватиметься 5 разів і додаватиме числа від 0 до 4 до `ourArray`.
|
||||
|
||||
Спробуймо підготувати цикл while до роботи, розміщуючи значення в масиві даних.
|
||||
Спробуємо заставити цикл while працювати, передаючи значення до масиву.
|
||||
|
||||
# --instructions--
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5690307fddb111c6084545d7
|
||||
title: Логічна послідовність в інструкції «if else»
|
||||
title: Логічна послідовність в інструкції if else
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cwNvMUV'
|
||||
forumTopicId: 18228
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b4
|
||||
title: Цитування рядків з одинарними лапками
|
||||
title: Цитування рядків одинарними лапками
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cbQmnhM'
|
||||
forumTopicId: 18260
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244e0
|
||||
title: Заміна ланцюжків «if else» на switch
|
||||
title: Заміна ланцюжків if else на switch
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c3JE8fy'
|
||||
forumTopicId: 18266
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244c4
|
||||
title: Повернення початкового шаблона для функцій
|
||||
title: Повернення початкового шаблону функцій
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cQe39Sq'
|
||||
forumTopicId: 18272
|
||||
@@ -9,9 +9,9 @@ dashedName: return-early-pattern-for-functions
|
||||
|
||||
# --description--
|
||||
|
||||
Коли ви досягнули команди `return`, виконання поточної функції припиняється і об'єкт керування повертається до місця виклику.
|
||||
Коли досягається інструкція `return`, виконання поточної функції припиняється, а керування повертається до місця, де було викликано функцію.
|
||||
|
||||
**Наприклад**
|
||||
**Приклад**
|
||||
|
||||
```js
|
||||
function myFun() {
|
||||
@@ -22,54 +22,54 @@ function myFun() {
|
||||
myFun();
|
||||
```
|
||||
|
||||
Показане вище відобразить рядок `Hello` у консолі і поверне рядок `World`. Рядок `byebye` ніколи не відобразиться у консолі, тому що функція виходить з команди `return`.
|
||||
Вищеподане покаже рядок `Hello` на консолі та поверне рядок `World`. Рядок `byebye` ніколи не зобразиться на консолі, оскільки функція виходить з інструкції `return`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Модифікуйте функцію `abTest` і тому, якщо `a` або `b` дорівнюватиме менше `0`, функція відразу вийде зі значенням `undefined`.
|
||||
Змініть функцію `abTest` таким чином, що коли `a` або `b` буде менше за `0`, функція одразу вийде зі значенням `undefined`.
|
||||
|
||||
**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.
|
||||
**Підказка**
|
||||
Пам’ятайте, що <a href="https://www.freecodecamp.org/ukrainian/learn/javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables" target="_blank" rel="noopener noreferrer nofollow"><code>undefined</code> є ключовим словом</a>, а не рядком.
|
||||
|
||||
# --hints--
|
||||
|
||||
`abTest(2, 2)` повинен повернути число
|
||||
`abTest(2, 2)` повинна повертати число
|
||||
|
||||
```js
|
||||
assert(typeof abTest(2, 2) === 'number');
|
||||
```
|
||||
|
||||
`abTest(2, 2)` повинен повернути `8`
|
||||
`abTest(2, 2)` повинна повертати `8`
|
||||
|
||||
```js
|
||||
assert(abTest(2, 2) === 8);
|
||||
```
|
||||
|
||||
`abTest(-2, 2)` повинен повернути `undefined`
|
||||
`abTest(-2, 2)` повинна повертати `undefined`
|
||||
|
||||
```js
|
||||
assert(abTest(-2, 2) === undefined);
|
||||
```
|
||||
|
||||
`abTest(2, -2)` повинен повернути `undefined`
|
||||
`abTest(2, -2)` повинна повертати `undefined`
|
||||
|
||||
```js
|
||||
assert(abTest(2, -2) === undefined);
|
||||
```
|
||||
|
||||
`abTest(2, 8)` повинен повернути `18`
|
||||
`abTest(2, 8)` повинна повертати `18`
|
||||
|
||||
```js
|
||||
assert(abTest(2, 8) === 18);
|
||||
```
|
||||
|
||||
`abTest(3, 3)` повинен повернути `12`
|
||||
`abTest(3, 3)` повинна повертати `12`
|
||||
|
||||
```js
|
||||
assert(abTest(3, 3) === 12);
|
||||
```
|
||||
|
||||
`abTest(0, 0)` повинен повернути `0`
|
||||
`abTest(0, 0)` повинна повертати `0`
|
||||
|
||||
```js
|
||||
assert(abTest(0, 0) === 0);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5679ceb97cbaa8c51670a16b
|
||||
title: Повернення логічних значень з функцій
|
||||
title: Повернення булевих значень із функцій
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cp62qAQ'
|
||||
forumTopicId: 18273
|
||||
@@ -9,9 +9,9 @@ dashedName: returning-boolean-values-from-functions
|
||||
|
||||
# --description--
|
||||
|
||||
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.
|
||||
Як ви можете пригадати з <a href="/ukrainian/learn/javascript-algorithms-and-data-structures/basic-javascript/comparison-with-the-equality-operator" target="_blank" rel="noopener noreferrer nofollow">порівняння з оператором «дорівнює»</a>, всі оператори порівняння повертають булеве значення `true` або `false`.
|
||||
|
||||
Інколи люди використовують `if/else` команду для того, щоб зробити порівняння на зразок цього:
|
||||
Іноді люди використовують інструкцію `if/else`, щоб виконати порівняння:
|
||||
|
||||
```js
|
||||
function isEqual(a, b) {
|
||||
@@ -23,7 +23,7 @@ function isEqual(a, b) {
|
||||
}
|
||||
```
|
||||
|
||||
Але є кращий спосіб це зробити. Оскільки `===` повертає `true` або `false`, ми можемо повернути результат порівняння:
|
||||
Але існує кращий спосіб. Оскільки `===` повертає `true` або `false`, ми можемо повернути результат порівняння:
|
||||
|
||||
```js
|
||||
function isEqual(a, b) {
|
||||
@@ -33,23 +33,23 @@ function isEqual(a, b) {
|
||||
|
||||
# --instructions--
|
||||
|
||||
Виправте функцію `isLess` для того, щоб видалити `if/else` команду.
|
||||
Виправте функцію `isLess` так, щоб видалити інструкції `if/else`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`isLess(10, 15)` повинен повернути `true`
|
||||
`isLess(10, 15)` повинна повертати `true`
|
||||
|
||||
```js
|
||||
assert(isLess(10, 15) === true);
|
||||
```
|
||||
|
||||
`isLess(15, 10)` повинен повернути `false`
|
||||
`isLess(15, 10)` повинна повертати `false`
|
||||
|
||||
```js
|
||||
assert(isLess(15, 10) === false);
|
||||
```
|
||||
|
||||
Вам не слід використовувати будь-які `if` чи `else` команди
|
||||
Ви не повинні використовувати інструкції `if` або `else`
|
||||
|
||||
```js
|
||||
assert(!/if|else/g.test(code));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244dd
|
||||
title: Вибір з багатьох опцій за допомогою перемикачів
|
||||
title: Вибір із багатьох варіантів за допомогою інструкцій switch
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c4mv4fm'
|
||||
forumTopicId: 18277
|
||||
@@ -9,9 +9,9 @@ dashedName: selecting-from-many-options-with-switch-statements
|
||||
|
||||
# --description--
|
||||
|
||||
Якщо у вас є багато опцій для вибору, використовуйте команду <dfn>switch</dfn>. `switch` тести на значення і може мати багато <dfn> випадків </dfn> інструкцій, які визначають різні значення. Інструкції виконуються від першого узгодженого значення `case<code> до тих пір, поки <code>break<code> не відбудиться.</p>
|
||||
Якщо ви маєте багато варіантів для вибору, використовуйте інструкцію <dfn>switch</dfn>. Інструкція `switch` тестує значення та може мати багато інструкцій <dfn>case</dfn>, які визначають можливі значення. Інструкції виконуються від першого відповідного значення `case` до тих пір, поки не зіткнуться із `break`.
|
||||
|
||||
<p spaces-before="0">Ось наводиться приклад інструкції <code>switch`:
|
||||
Ось приклад інструкції `switch`:
|
||||
|
||||
```js
|
||||
switch (lowercaseLetter) {
|
||||
@@ -24,11 +24,11 @@ switch (lowercaseLetter) {
|
||||
}
|
||||
```
|
||||
|
||||
`case` значень перевіряється абсолютною рівністю (`===`). `break` пропонує JavaScript припинити виконання інструкцій. Якщо `break` пропущений, тоді наступна команда буде виконуватись.
|
||||
Значення `case` перевіряються за допомогою строгої рівності (`===`). `break` вказує JavaScript зупинити запущені інструкції. Якщо пропустити `break`, виконується наступна інструкція.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Напишіть команду switch, щоб встановити `answer` за наступних умов:
|
||||
Напишіть інструкцію switch, яка перевіряє `val` та встановлює `answer` для наступних умов:
|
||||
`1` - `alpha`
|
||||
`2` - `beta`
|
||||
`3` - `gamma`
|
||||
@@ -36,31 +36,31 @@ switch (lowercaseLetter) {
|
||||
|
||||
# --hints--
|
||||
|
||||
`caseInSwitch(1)` повинно відповідати значенню рядка `alpha`
|
||||
`caseInSwitch(1)` повинна мати значення рядка `alpha`
|
||||
|
||||
```js
|
||||
assert(caseInSwitch(1) === 'alpha');
|
||||
```
|
||||
|
||||
`caseInSwitch(2)` повинно відповідати значенню рядка `beta`
|
||||
`caseInSwitch(2)` повинна мати значення рядка `beta`
|
||||
|
||||
```js
|
||||
assert(caseInSwitch(2) === 'beta');
|
||||
```
|
||||
|
||||
`caseInSwitch(3)` повинно відповідати значенню рядка `gamma`
|
||||
`caseInSwitch(3)` повинна мати значення рядка `gamma`
|
||||
|
||||
```js
|
||||
assert(caseInSwitch(3) === 'gamma');
|
||||
```
|
||||
|
||||
`caseInSwitch(4)` повинно відповідати значенню рядка `delta`
|
||||
`caseInSwitch(4)` повинна мати значення рядка `delta`
|
||||
|
||||
```js
|
||||
assert(caseInSwitch(4) === 'delta');
|
||||
```
|
||||
|
||||
Не варто використовувати `if` або `else` команди
|
||||
Ви не повинні використовувати інструкції `if` чи `else`
|
||||
|
||||
```js
|
||||
assert(!/else/g.test(code) || !/if/g.test(code));
|
||||
|
||||
@@ -11,13 +11,13 @@ dashedName: shopping-list
|
||||
|
||||
Створіть список покупок у змінній `myList`. Список повинен бути багатовимірним масивом, який містить декілька підмасивів.
|
||||
|
||||
Перший елемент у кожному підмасиві повинен містити рядок з назвою одиниці. Другий елемент повинен бути числом, яке відображає кількість.
|
||||
Перший елемент у кожному підмасиві повинен містити рядок з назвою одиниці. Другим елементом повинне бути число, яке вказує кількість.
|
||||
|
||||
```js
|
||||
["Chocolate Bar", 15]
|
||||
```
|
||||
|
||||
У списку повинно бути щонайменше 5 підмасивів.
|
||||
У списку повинно бути принаймні 5 підмасивів.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -39,7 +39,7 @@ assert(hasString);
|
||||
assert(hasNumber);
|
||||
```
|
||||
|
||||
У списку має бути щонайменше 5 одиниць.
|
||||
У списку повинно бути принаймні 5 одиниць.
|
||||
|
||||
```js
|
||||
assert(count > 4);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244c6
|
||||
title: Стояти в черзі
|
||||
title: Станьте в чергу
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/ca8Q8tP'
|
||||
forumTopicId: 18307
|
||||
@@ -9,43 +9,43 @@ dashedName: stand-in-line
|
||||
|
||||
# --description--
|
||||
|
||||
В комп'ютерних науках <dfn>queue</dfn> це абстрактне поняття <dfn>Data Structure</dfn>, де усі елементи зберігають певний порядок. Нові елементи можуть бути додані до черги, а старі елементи - зняті з черги.
|
||||
<dfn>Черга</dfn> в комп’ютерних науках – це абстрактна <dfn>структура даних</dfn>, де усі елементи зберігають певний порядок. Нові елементи можна додати в кінець черги, а старі елементи знімають з початку.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Напишіть функцію `nextInLine`, аргументами якої є масив (`arr`) та число (`item`).
|
||||
Напишіть функцію `nextInLine`, яка приймає масив (`arr`) та число (`item`) як аргументи.
|
||||
|
||||
Додайте число до кінця масиву, а тоді видаліть перший елемент з масиву.
|
||||
|
||||
Функція `nextInLine` повинна повернути видалений елемент.
|
||||
Функція `nextInLine` повинна повертати видалений елемент.
|
||||
|
||||
# --hints--
|
||||
|
||||
`nextInLine([], 5)` має повернути до числа.
|
||||
`nextInLine([], 5)` повинна повертати число.
|
||||
|
||||
```js
|
||||
assert.isNumber(nextInLine([], 5));
|
||||
```
|
||||
|
||||
`nextInLine([], 1)` має повернути до `1`
|
||||
`nextInLine([], 1)` повинна повертати `1`
|
||||
|
||||
```js
|
||||
assert(nextInLine([], 1) === 1);
|
||||
```
|
||||
|
||||
`nextInLine([2], 1)` має повернути до `2`
|
||||
`nextInLine([2], 1)` повинна повертати `2`
|
||||
|
||||
```js
|
||||
assert(nextInLine([2], 1) === 2);
|
||||
```
|
||||
|
||||
`nextInLine([5,6,7,8,9], 1)` має повернути до `5`
|
||||
`nextInLine([5,6,7,8,9], 1)` повинна повертати `5`
|
||||
|
||||
```js
|
||||
assert(nextInLine([5, 6, 7, 8, 9], 1) === 5);
|
||||
```
|
||||
|
||||
Після `nextInLine(testArr, 10)`, код `testArr[4]` має стати `10`
|
||||
Після `nextInLine(testArr, 10)`, `testArr[4]` повинен бути `10`
|
||||
|
||||
```js
|
||||
nextInLine(testArr, 10);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7993c9c69feddfaeb8bdef
|
||||
title: Зберігання кількох значень в одній змінній, використовуючи масиви JavaScript
|
||||
title: Зберігання декількох значень в одній змінній за допомогою масивів JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/crZQWAm'
|
||||
forumTopicId: 18309
|
||||
@@ -9,9 +9,9 @@ dashedName: store-multiple-values-in-one-variable-using-javascript-arrays
|
||||
|
||||
# --description--
|
||||
|
||||
Зі змінними масивів `array` JavaScript, ми можемо зберігати частини даних в одному місці.
|
||||
Ми можемо зберігати деякі дані в одному місці завдяки змінним `array` у JavaScript.
|
||||
|
||||
Ви починаєте оголошення масиву з відкритої квадратної дужки, а завершуєте його закриваючи квадратною дужкою і ставлячи кому між кожним елементом приблизно так:
|
||||
Оголошення масиву починається з початкової квадратної дужки, закінчується кінцевою квадратною дужкою, а між кожним елементом ставиться кома:
|
||||
|
||||
```js
|
||||
const sandwich = ["peanut butter", "jelly", "bread"];
|
||||
@@ -29,13 +29,13 @@ const sandwich = ["peanut butter", "jelly", "bread"];
|
||||
assert(typeof myArray == 'object');
|
||||
```
|
||||
|
||||
Першим елементом у масиві `myArray` має бути рядок.
|
||||
Першим елементом у `myArray` повинен бути рядок.
|
||||
|
||||
```js
|
||||
assert(typeof myArray[0] !== 'undefined' && typeof myArray[0] == 'string');
|
||||
```
|
||||
|
||||
Другий пункт в `myArray` має бути числом.
|
||||
Другим елементом у `myArray` повинне бути число.
|
||||
|
||||
```js
|
||||
assert(typeof myArray[1] !== 'undefined' && typeof myArray[1] == 'number');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244a8
|
||||
title: Зберігання значень за допомогою оператора присвоєння
|
||||
title: Зберігання значень за допомогою оператора присвоювання
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cEanysE'
|
||||
forumTopicId: 18310
|
||||
@@ -9,7 +9,7 @@ dashedName: storing-values-with-the-assignment-operator
|
||||
|
||||
# --description--
|
||||
|
||||
In JavaScript ви можете зберігати значення в змінній <dfn>assignment</dfn> з оператором (`=`).
|
||||
У JavaScript можна зберігати значення в змінній за допомогою оператора <dfn>присвоювання</dfn> (`=`).
|
||||
|
||||
```js
|
||||
myVariable = 5;
|
||||
@@ -17,14 +17,14 @@ myVariable = 5;
|
||||
|
||||
Вона призначає `Number` зі значенням `5` до `myVariable`.
|
||||
|
||||
Якщо праворуч від оператора є будь-які розрахунки `=`, ті з них, які розташовані перед значенням належать до змінної зліва від оператора.
|
||||
Якщо праворуч від оператора `=` є будь-які розрахунки, вони виконуються до того, як значення буде присвоєно змінній ліворуч від оператора.
|
||||
|
||||
```js
|
||||
var myVar;
|
||||
myVar = 5;
|
||||
```
|
||||
|
||||
Спочатку, цей код створює змінну з ім'ям `myVar`. Тоді код присвоює `5` на `myVar`. Тепер, якщо `myVar` знову з'являється в коді, програма буде розглядати його так, як `5`.
|
||||
Спочатку цей код створює змінну під назвою `myVar`. Потім код присвоює `5` до `myVar`. Якщо `myVar` знову з’явиться у коді, програма розглядатиме її як `5`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -38,7 +38,7 @@ myVar = 5;
|
||||
assert(/var a;/.test(code));
|
||||
```
|
||||
|
||||
`a` має мати значення 7.
|
||||
`a` повинна мати значення 7.
|
||||
|
||||
```js
|
||||
assert(typeof a === 'number' && a === 7);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb4bdef
|
||||
title: Віднімати одне число від іншого використовуючи JavaScript
|
||||
title: Віднімання одного числа від іншого за допомогою JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cP3yQtk'
|
||||
forumTopicId: 18314
|
||||
@@ -9,11 +9,11 @@ dashedName: subtract-one-number-from-another-with-javascript
|
||||
|
||||
# --description--
|
||||
|
||||
Ми також можемо віднімати одне число від іншого.
|
||||
Ми також можемо відняти одне число від іншого.
|
||||
|
||||
JavaScript використовує символ `-` для віднімання.
|
||||
|
||||
**Наприклад**
|
||||
**Приклад**
|
||||
|
||||
```js
|
||||
const myVar = 12 - 6;
|
||||
@@ -22,17 +22,17 @@ const myVar = 12 - 6;
|
||||
`myVar` тепер матиме значення `6`.
|
||||
# --instructions--
|
||||
|
||||
Змініть `0` так, щоб сума дорівнювала `12`.
|
||||
Змініть `0` так, щоб різниця дорівнювала `12`.
|
||||
|
||||
# --hints--
|
||||
|
||||
The variable `difference` should be equal to `12`.
|
||||
Змінна `difference` повинна дорівнювати `12`.
|
||||
|
||||
```js
|
||||
assert(difference === 12);
|
||||
```
|
||||
|
||||
You should only subtract one number from `45`.
|
||||
Ви повинні відняти лише одне число від `45`.
|
||||
|
||||
```js
|
||||
assert(/difference=45-33;?/.test(__helpers.removeWhiteSpace(code)));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 567af2437cbaa8c51670a16c
|
||||
title: Тестування властивостей об'єктів
|
||||
title: Перевірка властивостей об’єктів
|
||||
challengeType: 1
|
||||
forumTopicId: 18324
|
||||
dashedName: testing-objects-for-properties
|
||||
@@ -8,9 +8,9 @@ dashedName: testing-objects-for-properties
|
||||
|
||||
# --description--
|
||||
|
||||
Іноді варто перевіряти чи даний об'єкт вже має певні властивості. Ми можемо використовувати метод об'єктів `.hasOwnProperty(propname)`, щоб визначити чи об'єкт має ім'я властивості. `.hasOwnProperty()` показує `true` чи `false`, в залежності чи властивість знайдена, чи ні.
|
||||
Іноді потрібно перевіряти, чи об'єкт має певну властивість. Ми можемо використати метод об'єктів `.hasOwnProperty(propname)`, щоб визначити, чи має цей об’єкт задану назву властивості. `.hasOwnProperty()` повертає `true` або `false`, якщо властивість знайдена чи не знайдена.
|
||||
|
||||
**Наприклад**
|
||||
**Приклад**
|
||||
|
||||
```js
|
||||
const myObj = {
|
||||
@@ -22,11 +22,11 @@ myObj.hasOwnProperty("top");
|
||||
myObj.hasOwnProperty("middle");
|
||||
```
|
||||
|
||||
Перший `hasOwnProperty` стає `true`, а другий - `false`.
|
||||
Перший `hasOwnProperty` повертає `true`, а другий повертає `false`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Змініть функцію `checkObj`, щоб перевірити чи об'єкт переданий до функції (`obj`) містить особливу властивість (`checkProp`). Якщо властивість знайдена, поверніть значення властивості. Якщо ні, поверніть `"Not Found"`.
|
||||
Змініть функцію `checkObj` так, щоб вона перевіряла, чи переданий до функції об’єкт (`obj`) містить певну властивість (`checkProp`). Якщо властивість знайдена, поверніть значення властивості. Якщо ні, поверніть `"Not Found"`.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ba
|
||||
title: Розуміння нестійкості рядка
|
||||
title: Незмінність рядка
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cWPVaUR'
|
||||
forumTopicId: 18331
|
||||
@@ -9,16 +9,16 @@ dashedName: understand-string-immutability
|
||||
|
||||
# --description--
|
||||
|
||||
У JavaScript, `String` значення <dfn>immutable</dfn>, означає, що їх не можна буде змінити після створення.
|
||||
Значення рядка (`String`) у JavaScript є <dfn>незмінним</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`:
|
||||
Наприклад, наступний код спричинить помилку, оскільки літеру `B` у рядку `Bob` не можна змінити на літеру `J`:
|
||||
|
||||
```js
|
||||
let myStr = "Bob";
|
||||
myStr[0] = "J";
|
||||
```
|
||||
|
||||
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:
|
||||
Зауважте, що це *не* означає, що `myStr` не можна повторно присвоїти. Єдиний спосіб змінити `myStr` – присвоїти нове значення:
|
||||
|
||||
```js
|
||||
let myStr = "Bob";
|
||||
@@ -27,11 +27,11 @@ myStr = "Job";
|
||||
|
||||
# --instructions--
|
||||
|
||||
Виправте призначення `myStr` так, щоб код містив рядок зі значенням `Hello World`, використовуючи підхід, показаний вище.
|
||||
Використовуючи приклад вище, виправте присвоєння `myStr` так, щоб значенням рядка було `Hello World`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`myStr` має мати значення рядка `Hello World`.
|
||||
`myStr` повинен мати значення рядка `Hello World`.
|
||||
|
||||
```js
|
||||
assert(myStr === 'Hello World');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7123c9c441eddfaeb5bdef
|
||||
title: Розуміння булевих значень
|
||||
title: Булеві значення
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c9Me8t4'
|
||||
forumTopicId: 301176
|
||||
@@ -9,9 +9,9 @@ dashedName: understanding-boolean-values
|
||||
|
||||
# --description--
|
||||
|
||||
Інший тип даних це <dfn>Boolean</dfn>. Булеві значення можуть мати лише два значення: `true` чи `false`. Фактично, це маленькі перемикачі, де `true` це "увімкнено" і `false` - "вимкнено". Ці два стани несумісні.
|
||||
Іншим типом даних є <dfn>булеві</dfn>. Булеві можуть мати лише два значення: `true` або `false`. По суті, це маленькі перемикачі, де `true` означає «увімкнено», а `false` означає «вимкнено». Ці два стани несумісні.
|
||||
|
||||
**Note:** Булеві вирази ніколи не записуються в дужках. Рядки `"true"` й `"false"` не булеві і не мають особливого значення в JavaScript.
|
||||
**Примітка:** булеві значення завжди записують без лапок. Рядки `"true"` та `"false"` не є булевими та не мають особливого значення у JavaScript.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -19,13 +19,13 @@ dashedName: understanding-boolean-values
|
||||
|
||||
# --hints--
|
||||
|
||||
Функція `welcomeToBooleans()` має повернути значення (`true` or `false`).
|
||||
Функція `welcomeToBooleans()` повинна повертати булеве значення (`true` або `false`).
|
||||
|
||||
```js
|
||||
assert(typeof welcomeToBooleans() === 'boolean');
|
||||
```
|
||||
|
||||
`welcomeToBooleans()` має повернути `true`.
|
||||
`welcomeToBooleans()` повинна повертати `true`.
|
||||
|
||||
```js
|
||||
assert(welcomeToBooleans() === true);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ab
|
||||
title: Розуміння врахування регістру в змінних
|
||||
title: Чуттєвість змінних до регістру
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cd6GDcD'
|
||||
forumTopicId: 18334
|
||||
@@ -9,13 +9,13 @@ dashedName: understanding-case-sensitivity-in-variables
|
||||
|
||||
# --description--
|
||||
|
||||
У JavaScript усі змінні та назви функцій існують з урахуванням регістру. Це означає, що написання з великої літери має значення.
|
||||
Усі назви змінних та функцій у JavaScript чуттєві до регістру. Це означає, що написання з великої літери має значення.
|
||||
|
||||
`MYVAR` - це не теж саме, що й `MyVar` чи `myvar`. Цілком можливо мати декілька різних змінних з одинаковою назвою, але різним відмінком. Наполегливо рекомендується, щоб, заради чіткості, ви *не* використовували цю мовну особливість.
|
||||
`MYVAR` – це не саме, що `MyVar` чи `myvar`. Ви можете мати декілька різних змінних з одинаковою назвою, але різним регістром. Заради чіткості рекомендовано *не* використовувати цю особливість мови.
|
||||
|
||||
**Найкраща практика**
|
||||
|
||||
Напишіть назви змінних у JavaScript в <dfn>camelCase</dfn>. У <dfn>camelCase</dfn>, у назвах змінних, які складаються з декількох слів, перше слово ми пишемо з малої букви, а першу букву кожного наступного слова - з великої.
|
||||
Напишіть назви змінних у JavaScript <dfn>верблюдячимРегістром</dfn>. Назви змінних <dfn>верблюдячимРегістром</dfn> складаються з декількох слів, де перше слово ми пишемо з малої букви, а першу букву кожного наступного слова пишемо з великої.
|
||||
|
||||
**Приклади:**
|
||||
|
||||
@@ -27,19 +27,19 @@ var thisVariableNameIsSoLong;
|
||||
|
||||
# --instructions--
|
||||
|
||||
Модифікуйте існуючі оголошення та завдання так, щоб їхні назви використовували <dfn>camelCase</dfn>.
|
||||
Змініть наявні оголошення та присвоєння так, щоб їхні назви були написані <dfn>верблюдячимРегістром</dfn>.
|
||||
|
||||
Не створюйте жодних нових змінних.
|
||||
|
||||
# --hints--
|
||||
|
||||
`studlyCapVar` має бути визначене і мати значення `10`.
|
||||
`studlyCapVar` повинна бути визначеною та мати значення `10`.
|
||||
|
||||
```js
|
||||
assert(typeof studlyCapVar !== 'undefined' && studlyCapVar === 10);
|
||||
```
|
||||
|
||||
`properCamelCase` має бути визначене і мати значення рядка `A String`.
|
||||
`properCamelCase` повинна бути визначеною та мати значення рядка `A String`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@@ -47,25 +47,25 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`titleCaseOver` має бути визначене і мати значення `9000`.
|
||||
`titleCaseOver` повинна бути визначеною та мати значення `9000`.
|
||||
|
||||
```js
|
||||
assert(typeof titleCaseOver !== 'undefined' && titleCaseOver === 9000);
|
||||
```
|
||||
|
||||
`studlyCapVar` має використовувати camelCase як в оголошенні, так і в розділах завдань.
|
||||
`studlyCapVar` повинна використовувати верблюдячийРегістр як в оголошенні, так і в присвоєнні.
|
||||
|
||||
```js
|
||||
assert(code.match(/studlyCapVar/g).length === 2);
|
||||
```
|
||||
|
||||
`properCamelCase` має використовувати camelCase як в оголошенні, так і в розділах завдань.
|
||||
`properCamelCase` повинна використовувати верблюдячийРегістр як в оголошенні, так і в присвоєнні.
|
||||
|
||||
```js
|
||||
assert(code.match(/properCamelCase/g).length === 2);
|
||||
```
|
||||
|
||||
`titleCaseOver` має використовувати camelCase як в оголошенні, так і в розділах завдань.
|
||||
`titleCaseOver` повинна використовувати верблюдячийРегістр як в оголошенні, так і в присвоєнні.
|
||||
|
||||
```js
|
||||
assert(code.match(/titleCaseOver/g).length === 2);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 598e8944f009e646fc236146
|
||||
title: Розуміння невизначеного значення, яке повернуто з функції
|
||||
title: Невизначене значення, повернуте з функції
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/ce2p7cL'
|
||||
forumTopicId: 301177
|
||||
@@ -9,7 +9,7 @@ dashedName: understanding-undefined-value-returned-from-a-function
|
||||
|
||||
# --description--
|
||||
|
||||
Функція може містити команду `return`, але не обов'язково. У цьому випадку функція не має команди `return`. Натомість, коли ви викликаєте її, функція обробляє внутрішній код, але повернене значення є `undefined`.
|
||||
Функція може містити інструкцію `return`, але це необов'язково. Якщо функція не має інструкції `return`, то під час виклику функція обробляє внутрішній код, але поверненим значенням є `undefined`.
|
||||
|
||||
**Приклад**
|
||||
|
||||
@@ -23,33 +23,33 @@ function addSum(num) {
|
||||
addSum(3);
|
||||
```
|
||||
|
||||
`addSum` - це функція без команди `return`. Функція змінить загальну `sum` (суму) змінної, але повернене значення функції буде `undefined`.
|
||||
`addSum` є функцією без інструкції `return`. Функція змінить глобальну змінну `sum`, але поверненим значенням функції буде `undefined`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Створіть функцію `addFive` без аргументів. Ця функція додає 5 до `sum` (суми) змінної, але повернене значення є `undefined`.
|
||||
Створіть функцію `addFive` без аргументів. Ця функція додає 5 до змінної `sum`, але поверненим значенням є `undefined`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`addFive` має бути функцією.
|
||||
`addFive` повинна бути функцією.
|
||||
|
||||
```js
|
||||
assert(typeof addFive === 'function');
|
||||
```
|
||||
|
||||
Після запуску обидвох функцій, `sum` має дорівнювати `8`.
|
||||
Після запуску обидвох функцій, `sum` повинна дорівнювати `8`.
|
||||
|
||||
```js
|
||||
assert(sum === 8);
|
||||
```
|
||||
|
||||
Повернене з `addFive` значення, має бути `undefined`.
|
||||
Поверненим значенням з `addFive` повинне бути `undefined`.
|
||||
|
||||
```js
|
||||
assert(addFive() === undefined);
|
||||
```
|
||||
|
||||
Всередині функції `addFive` вам слід додати `5` до `sum` змінної.
|
||||
Всередині функції `addFive` ви повинні додати `5` до змінної `sum`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244aa
|
||||
title: Розуміння неініціалізованих змінних
|
||||
title: Неініціалізовані змінні
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cBa2JAL'
|
||||
forumTopicId: 18335
|
||||
@@ -9,7 +9,7 @@ dashedName: understanding-uninitialized-variables
|
||||
|
||||
# --description--
|
||||
|
||||
Коли змінні 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`.
|
||||
Коли змінні у JavaScript оголошено, вони отримують початкове значення `undefined`. Якщо виконати математичну дію на змінній `undefined`, то результатом буде `NaN`, що означає «Not a Number» <dfn>(укр. «не є числом»)</dfn>. Якщо об’єднати рядок зі змінною `undefined`, ви отримаєте <dfn>рядок</dfn> з `undefined`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@@ -17,25 +17,25 @@ dashedName: understanding-uninitialized-variables
|
||||
|
||||
# --hints--
|
||||
|
||||
`a` should be defined and have a final value of `6`.
|
||||
`a` повинна бути визначеною та мати кінцеве значення `6`.
|
||||
|
||||
```js
|
||||
assert(typeof a === 'number' && a === 6);
|
||||
```
|
||||
|
||||
`b` should be defined and have a final value of `15`.
|
||||
`b` повинна бути визначеною та мати кінцеве значення `15`.
|
||||
|
||||
```js
|
||||
assert(typeof b === 'number' && b === 15);
|
||||
```
|
||||
|
||||
`c` should not contain `undefined` and should have a final value of the string `I am a String!`
|
||||
`c` не повинна містити `undefined` та повинна мати кінцеве значення рядка `I am a String!`
|
||||
|
||||
```js
|
||||
assert(!/undefined/.test(c) && c === 'I am a String!');
|
||||
```
|
||||
|
||||
Вам не слід змінювати код під зазначеним коментарем.
|
||||
Не змінюйте код під зазначеним коментарем.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
||||
@@ -9,7 +9,7 @@ dashedName: updating-object-properties
|
||||
|
||||
# --description--
|
||||
|
||||
Після того, як ви створили об'єкт JavaScript, ви можете оновити його властивості в будь-який час, так як і будь-які інші його змінні. Ви можете використовувати точкову або дужкову нотацію для оновлення.
|
||||
Після створення об’єкта JavaScript ви можете будь-коли оновити його властивості так само, як оновлювали б будь-яку іншу змінну. Для оновлення можна використати точкову або дужкову нотацію.
|
||||
|
||||
Наприклад, погляньмо на `ourDog`:
|
||||
|
||||
@@ -22,21 +22,21 @@ const ourDog = {
|
||||
};
|
||||
```
|
||||
|
||||
Оскільки це винятково щасливий собака, змінімо його ім'я на рядок `Happy Camper`. Ось як ми оновимо властивість імені його об'єкта: `ourDog.name = "Happy Camper";` або `ourDog["name"] = "Happy Camper";` Тепер коли ми оцінюємо `ourDog.name`, замість того, щоб отримати `Camper`, ми отримаємо його нове ім'я `Happy Camper`.
|
||||
Оскільки це особливо щаслива собака, змінимо його ім'я на рядок `Happy Camper`. Ось як ми оновлюємо властивість назви об’єкта: `ourDog.name = "Happy Camper";` або `ourDog["name"] = "Happy Camper";`. Тепер, коли ми визначаємо `ourDog.name`, замість `Camper` ми отримуватимемо нове ім’я `Happy Camper`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Оновити властивість імені об'єкта `myDog`. Змінімо його ім'я з `Coder` на `Happy Coder`. Ви можете використати точкову або дужкову нотацію.
|
||||
Оновіть властивість імені об'єкта `myDog`. Змінимо ім'я з `Coder` на `Happy Coder`. Ви можете використати точкову або дужкову нотацію.
|
||||
|
||||
# --hints--
|
||||
|
||||
Вам слід оновити властивість `name` `myDog`, щоб вона дорівнювала рядку`Happy Coder`.
|
||||
Ви повинні оновити властивість `name` об’єкта `myDog`, щоб вона дорівнювала рядку `Happy Coder`.
|
||||
|
||||
```js
|
||||
assert(/happy coder/gi.test(myDog.name));
|
||||
```
|
||||
|
||||
Не слід змінювати визначення `myDog`.
|
||||
Ви не повинні редагувати визначення `myDog`.
|
||||
|
||||
```js
|
||||
assert(/"name": "Coder"/.test(code));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7123c9c549eddfaeb5bdef
|
||||
title: Використовуйте Дужкову Нотацію для Пошуку Першого Символу в Рядку
|
||||
title: Дужкова нотація для пошуку першого символа рядка
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/ca8JwhW'
|
||||
forumTopicId: 18341
|
||||
@@ -9,26 +9,26 @@ dashedName: use-bracket-notation-to-find-the-first-character-in-a-string
|
||||
|
||||
# --description--
|
||||
|
||||
<dfn>Дужкова нотація</dfn> - це спосіб отримання символу з певним індексом в рядку.
|
||||
Завдяки <dfn>дужковій нотації</dfn> можна отримати символ з певним індексом в рядку.
|
||||
|
||||
Більшість сучасних мов програмування, таких як JavaScript, не починають рахувати з 1, як це роблять люди. Вони починають з 0. Це називають індексація <dfn>на основі нуля</dfn>.
|
||||
Більшість сучасних мов програмування, наприклад JavaScript, не починають рахунок з 1, як це роблять люди. Вони починають з 0. Це називається індексацією <dfn>на основі нуля</dfn>.
|
||||
|
||||
Наприклад, символ з індексом 0 у слові `Charles` буде `C`. Отже, якщо `const firstName = "Charles"`, ви можете отримати значення першої літери рядка, використовуючи `firstName[0]`.
|
||||
Наприклад, символом з індексом 0 у слові `Charles` буде `C`. Тому, якщо `const firstName = "Charles"`, ви можете отримати значення першої літери рядка, використовуючи `firstName[0]`.
|
||||
|
||||
Наприклад:
|
||||
Приклад:
|
||||
|
||||
```js
|
||||
const firstName = "Charles";
|
||||
const firstLetter = firstName[0];
|
||||
```
|
||||
|
||||
`firstLetter` повинна мати значення рядка `C`.
|
||||
`firstLetter` матиме значення рядка `C`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Використовуйте дужкову нотацію, щоб знайти перший символ в змінній `lastName` та задайте його до `firstLetterOfLastName`.
|
||||
Використайте дужкову нотацію, щоб знайти перший символ у змінній `lastName` та призначте його до `firstLetterOfLastName`.
|
||||
|
||||
**Підказка:**Спробуйте подивитися на приклад вище, якщо застрягли.
|
||||
**Підказка:** якщо застрягли, перегляньте вищеподаний приклад.
|
||||
|
||||
# --hints--
|
||||
|
||||
@@ -38,7 +38,7 @@ const firstLetter = firstName[0];
|
||||
assert(firstLetterOfLastName === 'L');
|
||||
```
|
||||
|
||||
Вам слід використовувати дужкову нотацію.
|
||||
Ви повинні використати дужкову нотацію.
|
||||
|
||||
```js
|
||||
assert(code.match(/firstLetterOfLastName\s*=\s*lastName\s*\[\s*\d\s*\]/));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7123c9c451eddfaeb5bdef
|
||||
title: Використовуйте Дужкову Нотацію для Пошуку Останнього Символу в Рядку
|
||||
title: Дужкова нотація для пошуку останнього символа рядка
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cBZQGcv'
|
||||
forumTopicId: 18342
|
||||
@@ -9,28 +9,28 @@ dashedName: use-bracket-notation-to-find-the-last-character-in-a-string
|
||||
|
||||
# --description--
|
||||
|
||||
Щоб отримати останню літеру рядка, ви можете відняти її від довжини рядка.
|
||||
Щоб отримати останню літеру рядка, можна відняти одиницю від довжини рядка.
|
||||
|
||||
Наприклад, якщо `const firstName = "Ada"`, ви можете отримати значення останньої літери, використовуючи `firstName[firstName.length - 1]`.
|
||||
Наприклад, якщо `const firstName = "Ada"`, ви можете отримати значення останньої літери, використавши `firstName[firstName.length - 1]`.
|
||||
|
||||
Наприклад:
|
||||
Приклад:
|
||||
|
||||
```js
|
||||
const firstName = "Ada";
|
||||
const lastLetter = firstName[firstName.length - 1];
|
||||
```
|
||||
|
||||
`lastLetter` повинна мати значення рядка `a`.
|
||||
`lastLetter` матиме значення рядка `a`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Використовуйте <dfn>дужкову нотацію</dfn>, щоб знайти останній символ у змінній `lastName`.
|
||||
Використайте <dfn>дужкову нотацію</dfn>, щоб знайти останній символ у змінній `lastName`.
|
||||
|
||||
**Підказка:**Спробуйте подивитися на приклад вище, якщо застрягли.
|
||||
**Підказка:** якщо застрягли, перегляньте вищеподаний приклад.
|
||||
|
||||
# --hints--
|
||||
|
||||
`lastLetterOfLastName` повинно бути літерою `e`.
|
||||
`lastLetterOfLastName` повинна бути літера `e`.
|
||||
|
||||
```js
|
||||
assert(lastLetterOfLastName === 'e');
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user