Created
November 7, 2014 18:21
-
-
Save funnierinspanish/c9f0ac78cc1b8664b721 to your computer and use it in GitHub Desktop.
Converts camel or bumpy cased strings to human readable space separated strings
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
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