Skip to content

Instantly share code, notes, and snippets.

@mtio
Created May 3, 2016 22:40
Show Gist options
  • Select an option

  • Save mtio/614aaf729eead5cfc277f04c5b4a38f0 to your computer and use it in GitHub Desktop.

Select an option

Save mtio/614aaf729eead5cfc277f04c5b4a38f0 to your computer and use it in GitHub Desktop.
How to explode a camel cased string
filters: {
'explodingCamels': function(string) {
var toReturn = '';
for (var i = 0; i < string.length; i++) {
var character = string.charAt(i);
if (isNaN(character * 1)) {
if (i != 0 && character == character.toUpperCase()) {
toReturn += ' ';
}
}
toReturn += character;
}
return toReturn;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment