Last active
November 19, 2020 18:48
-
-
Save eday69/0da130c8764564a7e1efdecc2fa57799 to your computer and use it in GitHub Desktop.
freeCodeCamp Intermediate Algorithm Scripting: Spinal Tap Case
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
// Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes. | |
function spinalCase(str) { | |
// "It's such a fine line between stupid, and clever." | |
// --David St. Hubbins | |
return str.split(/\s|_|(?=[A-Z])/).join("-").toLowerCase(); | |
} | |
spinalCase('This Is Spinal Tap'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment