Created
October 22, 2014 19:51
-
-
Save rmccullagh/db8bcdb0adc06ff85a05 to your computer and use it in GitHub Desktop.
Reverse Camel Case implementation
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
function camel_case_rev(word) | |
{ | |
if(! word) | |
return; | |
word = (word).toString(); | |
var ret = ""; | |
for(var i = 0; i < word.length; i++) | |
{ | |
if(word[i] <= 'Z' && word[i] >= 'A') | |
{ | |
ret += String.prototype.toLowerCase.call(word[i]); | |
} | |
else if(word[i] <= 'z' && word[i] >= 'a') | |
{ | |
ret += String.prototype.toUpperCase.call(word[i]); | |
} | |
// non alpha | |
else | |
{ | |
ret += word[i]; | |
} | |
} | |
return ret; | |
} | |
prog = process.argv[1]; | |
if(process.argv.length < 3) { | |
console.log("USAGE: " + prog + " <string>"); | |
process.exit(); | |
} | |
console.log(camel_case_rev(process.argv[2])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment