-
-
Save utsukushiihime/5c39423d8597f1dff7408b3ff79c0069 to your computer and use it in GitHub Desktop.
toSnakeCase JavaScript
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
function SnakeCase(str) { | |
const regex = /\W+/g; | |
for (char in str) { | |
let newStr = str.toLowerCase().replace(regex, "_"); | |
return newStr; | |
} | |
} | |
console.log(SnakeCase("This*is a Great-Night")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment