Created
March 26, 2019 21:41
-
-
Save yojona/3ad63ce60e7c1d72a00f0568bd26ecca 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 toCamelCase = string => { | |
return string.replace(/^([A-Z])|[\s-_](\w)/g, (match, p1, p2, offset) => { | |
if (p2) return p2.toUpperCase(); | |
return p1.toLowerCase(); | |
}); | |
} | |
console.log(toCamelCase("Hola perro")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment