Skip to content

Commit 1c9ea6e

Browse files
authored
Merge pull request #360 from NexGenUA/patch-2
Update solution.md
2 parents 6f3bc97 + 0437329 commit 1c9ea6e

File tree

1 file changed

+12
-0
lines changed
  • 1-js/05-data-types/05-array-methods/1-camelcase

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
```js run demo
2+
function camelize(str) {
3+
return str
4+
.split('-') // разбивает 'my-long-word' на массив ['my', 'long', 'word']
5+
.map(
6+
// Переводит в верхний регистр первые буквы всех элементом массива за исключением первого
7+
// превращает ['my', 'long', 'word'] в ['my', 'Long', 'Word']
8+
(word, index) => index == 0 ? word : word[0].toUpperCase() + word.slice(1)
9+
)
10+
.join(''); // соединяет ['my', 'Long', 'Word'] в 'myLongWord'
11+
}
12+
```

0 commit comments

Comments
 (0)