Skip to content

Instantly share code, notes, and snippets.

@eser
Last active November 14, 2022 18:46
Show Gist options
  • Save eser/5445e61367d4002d52f0e92085618fd2 to your computer and use it in GitHub Desktop.
Save eser/5445e61367d4002d52f0e92085618fd2 to your computer and use it in GitHub Desktop.
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