Skip to content

Commit 9c047c7

Browse files
first try
1 parent ee3c9e7 commit 9c047c7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

6kyus/js/convertStringToCamelCase.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ function toCamelCase(str) {
1414
return word
1515
})
1616
return returnString.join('')
17+
} else if (str.includes('_')) {
18+
returnString = str.split('_').map((word, idx) => {
19+
if (idx > 0) {
20+
return `${word.charAt(0).toUpperCase()}${word.slice(1)}`
21+
}
22+
return word
23+
})
24+
return returnString.join('')
1725
}
1826
// Split on dash or underscore
1927
// loop over each element in array and capitalize first character starting from index 1

0 commit comments

Comments
 (0)