Skip to content

Commit 1d7ff5c

Browse files
Merge pull request #133 from RafalMichniuk/master
Strings
2 parents f4ddb22 + 2281d2e commit 1d7ff5c

File tree

12 files changed

+265
-269
lines changed

12 files changed

+265
-269
lines changed
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
describe("ucFirst", function() {
2-
it('Uppercases the first symbol', function() {
2+
it('Zmienia pierwszy znak na wielką literę', function() {
33
assert.strictEqual(ucFirst("john"), "John");
44
});
55

6-
it("Doesn't die on an empty string", function() {
6+
it("Nie wysypuje się na pustym łańcuchu", function() {
77
assert.strictEqual(ucFirst(""), "");
88
});
9-
});
9+
});

Diff for: 1-js/05-data-types/03-string/1-ucfirst/solution.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
We can't "replace" the first character, because strings in JavaScript are immutable.
1+
Nie możemy "zastąpić" pierwszego znaku, ponieważ łańcuchy znaków w JavaScript są niezmienne.
22

3-
But we can make a new string based on the existing one, with the uppercased first character:
3+
Możemy jednak stworzyć nowy łańcuch na podstawie istniejącego z pierwszym znakiem, jako wielką literą:
44

55
```js
66
let newStr = str[0].toUpperCase() + str.slice(1);
77
```
88

9-
There's a small problem though. If `str` is empty, then `str[0]` is `undefined`, and as `undefined` doesn't have the `toUpperCase()` method, we'll get an error.
9+
Jest jednak mały problem. Jeśli `str` jest pusty, to `str[0]` zwróci `undefined`, a `undefined` nie ma metody `toUpperCase()`, więc otrzymamy błąd.
1010

11-
There are two variants here:
11+
Są dwa wyjścia:
1212

13-
1. Use `str.charAt(0)`, as it always returns a string (maybe empty).
14-
2. Add a test for an empty string.
13+
1. Użyj `str.charAt(0)`, ponieważ ta metoda zawsze zwraca łańcuch znaków (może być pusty).
14+
2. Dodaj warunek na wypadek pustego łańcucha.
1515

16-
Here's the 2nd variant:
16+
Oto druga opcja:
1717

1818
```js run demo
1919
function ucFirst(str) {

Diff for: 1-js/05-data-types/03-string/1-ucfirst/task.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 5
22

33
---
44

5-
# Uppercase the first character
5+
# Zrób pierwszy znak wielką literą
66

7-
Write a function `ucFirst(str)` that returns the string `str` with the uppercased first character, for instance:
7+
Napisz funkcję `ucFirst(str)`, która zwraca ciąg `str` z pierwszym znakiem wielką literą. Na przykład:
88

99
```js
1010
ucFirst("john") == "John";
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
describe("checkSpam", function() {
2-
it('finds spam in "buy ViAgRA now"', function() {
2+
it('uważa "buy ViAgRA now" za spam', function() {
33
assert.isTrue(checkSpam('buy ViAgRA now'));
44
});
55

6-
it('finds spam in "free xxxxx"', function() {
6+
it('uważa "free xxxxx" za spam', function() {
77
assert.isTrue(checkSpam('free xxxxx'));
88
});
99

10-
it('no spam in "innocent rabbit"', function() {
10+
it('nie uważa "innocent rabbit" za spam', function() {
1111
assert.isFalse(checkSpam('innocent rabbit'));
1212
});
1313
});

Diff for: 1-js/05-data-types/03-string/2-check-spam/solution.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
To make the search case-insensitive, let's bring the string to lower case and then search:
1+
Aby wyszukiwanie działało bez względu na wielkość liter, przekonwertujemy cały łańcuch na małe litery, a następnie sprawdzimy, czy zawiera szukany ciąg znaków:
22

33
```js run demo
44
function checkSpam(str) {

Diff for: 1-js/05-data-types/03-string/2-check-spam/task.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ importance: 5
22

33
---
44

5-
# Check for spam
5+
# Sprawdzanie pod kątem spamu
66

7-
Write a function `checkSpam(str)` that returns `true` if `str` contains 'viagra' or 'XXX', otherwise `false`.
7+
Napisz funkcję `checkSpam(str)`, która zwraca `true` jeśli `str` zawiera 'viagra' lub 'XXX', w przeciwnym wypadku `false`.
88

9-
The function must be case-insensitive:
9+
Funkcja musi być niewrażliwa na wielkość liter:
1010

1111
```js
1212
checkSpam('buy ViAgRA now') == true

Diff for: 1-js/05-data-types/03-string/3-truncate/_js.view/test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
describe("truncate", function() {
2-
it("truncate the long string to the given length (including the ellipsis)", function() {
2+
it("obcina ciąg do podanej długości (łącznie z wielokropkiem)", function() {
33
assert.equal(
4-
truncate("What I'd like to tell on this topic is:", 20),
5-
"What I'd like to te…"
4+
truncate("Oto, co chciałbym powiedzieć na ten temat:", 20),
5+
"Oto, co chciałbym p…"
66
);
77
});
88

9-
it("doesn't change short strings", function() {
9+
it("nie zmienia krótkich łańcuchów", function() {
1010
assert.equal(
11-
truncate("Hi everyone!", 20),
12-
"Hi everyone!"
11+
truncate("Cześć wszystkim!", 20),
12+
"Cześć wszystkim!"
1313
);
1414
});
1515

Diff for: 1-js/05-data-types/03-string/3-truncate/solution.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
The maximal length must be `maxlength`, so we need to cut it a little shorter, to give space for the ellipsis.
1+
Zwracany ciąg nie może być dłuższy niż `maxlength`, więc jeśli go skrócimy, to musimy usunąć o jeden znak mniej, aby zrobić miejsce na wielokropek.
22

3-
Note that there is actually a single unicode character for an ellipsis. That's not three dots.
3+
Należy pamiętać, że wielokropek to '…' – dokładnie jeden znak specjalny Unicode. To nie to samo, co '. . .' – trzy kropki.
44

55
```js run demo
66
function truncate(str, maxlength) {

Diff for: 1-js/05-data-types/03-string/3-truncate/task.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ importance: 5
22

33
---
44

5-
# Truncate the text
5+
# Obcinanie tekstu
66

7-
Create a function `truncate(str, maxlength)` that checks the length of the `str` and, if it exceeds `maxlength` -- replaces the end of `str` with the ellipsis character `"…"`, to make its length equal to `maxlength`.
7+
Utwórz funkcję `truncate(str, maxlength)`, która sprawdza długość łańcucha `str` i jeśli przekracza `maxlength`, zamienia koniec `str` na ``, tak aby jego długość była równa `maxlength`.
88

9-
The result of the function should be the truncated (if needed) string.
9+
Wynik funkcji musi być tym samym ciągiem, jeśli obcięcie nie jest wymagane lub obciętym ciągiem, jeśli to konieczne.
1010

11-
For instance:
11+
Na przykład:
1212

1313
```js
14-
truncate("What I'd like to tell on this topic is:", 20) = "What I'd like to te"
14+
truncate("Oto, co chciałbym powiedzieć na ten temat:", 20) = "Oto, co chciałbym p"
1515

16-
truncate("Hi everyone!", 20) = "Hi everyone!"
16+
truncate("Cześć wszystkim!", 20) = "Cześć wszystkim!"
1717
```

Diff for: 1-js/05-data-types/03-string/4-extract-currency/_js.view/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
describe("extractCurrencyValue", function() {
22

3-
it("for the string $120 returns the number 120", function() {
3+
it("dla ciągu $120 zwraca numer 120", function() {
44
assert.strictEqual(extractCurrencyValue('$120'), 120);
55
});
66

Diff for: 1-js/05-data-types/03-string/4-extract-currency/task.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 4
22

33
---
44

5-
# Extract the money
5+
# Wyciągnij liczbę
66

7-
We have a cost in the form `"$120"`. That is: the dollar sign goes first, and then the number.
7+
Mamy koszty zapisane w postaci ciągu `"$120"`. Oznacza to, że najpierw pojawia się znak dolara, a następnie liczba.
88

9-
Create a function `extractCurrencyValue(str)` that would extract the numeric value from such string and return it.
9+
Stwórz funkcję `extractCurrencyValue(str)` która wydobędzie wartość liczbową z takiego ciągu i ją zwróci.
1010

11-
The example:
11+
Na przykład:
1212

1313
```js
1414
alert( extractCurrencyValue('$120') === 120 ); // true

0 commit comments

Comments
 (0)