We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0109c44 commit f6cc3a4Copy full SHA for f6cc3a4
src/lib/toCamelCase.js
@@ -3,14 +3,11 @@ import assertString from "./util/assertString";
3
export default function toCamelCase(inputString) {
4
assertString(inputString);
5
6
- // Split the input string into words using spaces, hyphens, or underscores as separators
7
const words = inputString.split(/[\s\-_]+/);
8
9
- // Capitalize the first letter of each word except the first one
10
- for (let i = 1; i < words.length; i++) {
11
- words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1);
12
- }
+ words.map((word) => {
+ return word.charAt(0).toUpperCase() + word.slice(1);
+ });
13
14
- // Join the words back together to form the camelCase string
15
- return words.join('');
+ return words.join("");
16
}
0 commit comments