Skip to content

Instantly share code, notes, and snippets.

@funnierinspanish
Created November 7, 2014 18:21
Show Gist options
  • Save funnierinspanish/c9f0ac78cc1b8664b721 to your computer and use it in GitHub Desktop.
Save funnierinspanish/c9f0ac78cc1b8664b721 to your computer and use it in GitHub Desktop.
Converts camel or bumpy cased strings to human readable space separated strings
var decaser = function(input){
var newStr = [],
resultStr;
for( var i = 0 ; i < input.length ; i++ ){
if(input.substring(i,i+1) === input.substring(i,i+1).toUpperCase()){
var spacedDecased = " "+input.substring(i,i+1).toLowerCase();
newStr.push(spacedDecased);
}else{
newStr.push(input.substring(i,i+1))
}
}
resultStr = newStr.join('');
return resultStr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment