Skip to content

Instantly share code, notes, and snippets.

@SeanJM
Created December 23, 2015 14:27
Show Gist options
  • Save SeanJM/50233e16793ad62e844a to your computer and use it in GitHub Desktop.
Save SeanJM/50233e16793ad62e844a to your computer and use it in GitHub Desktop.
A function which 'kebab' cases a string
function kebabCase(string) {
return string.split(/ |_|-/).join('-').split('').map(function (a) {
if (a.toUpperCase() === a && a !== '-') {
return '-' + a.toLowerCase();
}
return a;
}).join('').toLowerCase();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment