Last changes

This commit is contained in:
Volodymyr Shevchuk 2021-05-03 15:15:32 +03:00
parent b24b05d3ca
commit fdc015e1fa
8 changed files with 59 additions and 32 deletions

View file

@ -1,3 +1,10 @@
function camelize(str) {
/* your code */
}
return str
.split('-') // разбивает 'my-long-word' на массив ['my', 'long', 'word']
.map(
// Переводит в верхний регистр первые буквы всех элементом массива за исключением первого
// превращает ['my', 'long', 'word'] в ['my', 'Long', 'Word']
(word, index) => index == 0 ? word : word[0].toUpperCase() + word.slice(1)
)
.join(''); // соединяет ['my', 'Long', 'Word'] в 'myLongWord'
}