Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 725f076

Browse files
authored
Fix alert for string method examples
Added additional explanations in the code snippets
1 parent 6964d80 commit 725f076

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎1-js/05-data-types/03-string/article.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ alert( str.charAt(0) ); // П
140140
141141
// останній символ
142142
alert( str[str.length - 1] ); // т
143-
alert( str.at(-1) );
143+
alert( str.at(-1) ); // т
144144
```
145145

146146
Як бачите, перевага методу `.at(pos)` полягає в тому, що він допускає від'ємну позицію. Якщо `pos` від'ємне число, тоді позиція відраховується з кінця рядка.
@@ -174,7 +174,7 @@ for (let char of "Привіт") {
174174
let str = 'Ой';
175175

176176
str[0] = 'о'; // помилка
177-
alert( str[0] ); // не працює
177+
alert( str[0] ); // не працює, тому що у попередньому рядку помилка
178178
```
179179

180180
Можна створити новий рядок замість старого, записавши його в ту саму змінну.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /