728x90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://javascript.info/array-methods#tasks | |
// Q. Translate border-left-width to borderLeftWidth | |
function camelize(str) { | |
return str | |
.split('-') | |
.map((word, index) => index === 0 ? word : word[0].toUpperCase() + word.slice(1)) | |
.join('') | |
} | |
const str1 = 'border-left-width'; | |
const str2 = 'background-color'; | |
const str3 = 'list-style-image'; | |
const str4 = '-webkit-transition'; | |
const result1 = camelize(str1); | |
const result2 = camelize(str2); | |
const result3 = camelize(str3); | |
const result4 = camelize(str4); | |
console.log(result1); | |
console.log(result2); | |
console.log(result3); | |
console.log(result4); |
'Algorithm > JavaScript(Node.js)' 카테고리의 다른 글
The Modern JS Tutorial: array-methods: filterRangeInPlace (0) | 2021.09.13 |
---|---|
The Modern JS Tutorial: array-methods: filterRange (0) | 2021.09.13 |
백준 15652번: N과 M (4) Node.js(JavaScript) (0) | 2020.02.27 |
백준 15651번: N과 M (3) Node.js(JavaScript) (0) | 2020.02.25 |
백준 15650번: N과 M (2) Node.js(JavaScript) (0) | 2020.02.24 |