Skip to content

Instantly share code, notes, and snippets.

@kevboutin
Last active October 17, 2023 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevboutin/6a350b583c0cc997d7ae9fe875e4cbac to your computer and use it in GitHub Desktop.
Save kevboutin/6a350b583c0cc997d7ae9fe875e4cbac to your computer and use it in GitHub Desktop.
Convert string in snake case to came case
const snakeToCamelCase = (s) =>
s.toLowerCase().replace(/(_\w)/g, (w) => w.toUpperCase().substr(1));
const str1 = 'string_manipulation';
const str2 = 'one_liner';
console.log(snakeToCamelCase(str1)); // stringManipulation
console.log(snakeToCamelCase(str2)); // oneLiner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment