Skip to content

Instantly share code, notes, and snippets.

@minsooshin
Last active November 22, 2015 04:00
Show Gist options
  • Save minsooshin/b5c2a6bc0acaa424c550 to your computer and use it in GitHub Desktop.
Save minsooshin/b5c2a6bc0acaa424c550 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/minsooshin 's solution for Bonfire: Spinal Tap Case
// Bonfire: Spinal Tap Case
// Author: @minsooshin
// Challenge: http://www.freecodecamp.com/challenges/bonfire-spinal-tap-case
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function spinalCase(str) {
// "It's such a fine line between stupid, and clever."
// --David St. Hubbins
str = str.replace(/([a-z])([A-Z])/g, '$1 $2')
.toLowerCase().replace(/\s/g, '-')
.replace(/_/g, '-');
return str;
}
spinalCase("This Is Spinal Tap");
spinalCase("thisIsSpinalTap");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment