Last active
November 14, 2022 18:46
-
-
Save eser/5445e61367d4002d52f0e92085618fd2 to your computer and use it in GitHub Desktop.
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
const camelCaps = (str) => { | |
let nextShouldBeUpper = true; | |
let result = ""; | |
for (let i = 0; i < str.length; i++) { | |
result += nextShouldBeUpper ? str[i].toLocaleUpperCase() : str[i].toLocaleLowerCase(); | |
nextShouldBeUpper = (str[i] === " ") || !nextShouldBeUpper; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment