Skip to content

Commit 3c47823

Browse files
committed
Merge branch 'master' of github.com:javascript-tutorial/uk.javascript.info
2 parents 727fed7 + a92f1be commit 3c47823

37 files changed

Lines changed: 474 additions & 464 deletions

File tree

‎.all-contributorsrc‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@
243243
"contributions": [
244244
"translation"
245245
]
246+
},
247+
{
248+
"login": "gingano",
249+
"name": "gingano",
250+
"avatar_url": "https://avatars.githubusercontent.com/u/47160813?v=4",
251+
"profile": "https://github.com/gingano",
252+
"contributions": [
253+
"translation"
254+
]
246255
}
247256
]
248257
}
Lines changed: 1 addition & 1 deletion
Loading

‎1-js/03-code-quality/01-debugging-chrome/chrome-open-sources.svg‎

Lines changed: 1 addition & 1 deletion
Loading

‎1-js/03-code-quality/01-debugging-chrome/chrome-sources-breakpoint.svg‎

Lines changed: 1 addition & 1 deletion
Loading

‎1-js/03-code-quality/01-debugging-chrome/chrome-sources-debugger-pause.svg‎

Lines changed: 1 addition & 1 deletion
Loading

‎1-js/03-code-quality/01-debugging-chrome/chrome-sources-debugger-trace-1.svg‎

Lines changed: 1 addition & 1 deletion
Loading

‎1-js/03-code-quality/02-coding-style/code-style.svg‎

Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 3 additions & 3 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('Перетворює перший символ у верхній регістр', function() {
33
assert.strictEqual(ucFirst("john"), "John");
44
});
55

6-
it("Doesn't die on an empty string", function() {
6+
it('Не вмирає на порожніх рядках', function() {
77
assert.strictEqual(ucFirst(""), "");
88
});
9-
});
9+
});
Lines changed: 8 additions & 8 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+
Ми не можемо "замінити" перший символ, оскільки рядки в JavaScript незмінні.
22

3-
But we can make a new string based on the existing one, with the uppercased first character:
3+
Але ми можемо створити новий рядок на основі існуючого, з першим символом у верхньому регістрі:
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+
Але є невелика проблема. Якщо `str` порожній рядок, то `str[0]` буде `undefined`, а оскільки `undefined` не має методу `toUpperCase()`, ми отримаємо помилку.
1010

11-
There are two variants here:
11+
Тут є два варіанти:
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. Використати `str.charAt(0)`, оскільки він завжди повертає рядок (навіть для порожнього рядка).
14+
2. Додати перевірку на порожній рядок.
1515

16-
Here's the 2nd variant:
16+
Ось 2-й варіант:
1717

1818
```js run demo
1919
function ucFirst(str) {
@@ -22,6 +22,6 @@ function ucFirst(str) {
2222
return str[0].toUpperCase() + str.slice(1);
2323
}
2424

25-
alert( ucFirst("john") ); // John
25+
alert( ucFirst("василь") ); // Василь
2626
```
2727

0 commit comments

Comments
 (0)