Last active
October 17, 2023 15:33
-
-
Save kevboutin/6a350b583c0cc997d7ae9fe875e4cbac to your computer and use it in GitHub Desktop.
Convert string in snake case to came case
This file contains hidden or 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 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