Skip to content

Commit 12b07a8

Browse files
03-string>1-ucfirst
1 parent 4cad987 commit 12b07a8

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed
Lines changed: 2 additions & 2 deletions
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 na pustym łańcuchu", function() {
77
assert.strictEqual(ucFirst(""), "");
88
});
99
});

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

Lines changed: 7 additions & 7 deletions
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) {

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

Lines changed: 2 additions & 2 deletions
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";

0 commit comments

Comments
 (0)