Skip to content

Instantly share code, notes, and snippets.

@rmccullagh
Created October 22, 2014 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmccullagh/db8bcdb0adc06ff85a05 to your computer and use it in GitHub Desktop.
Save rmccullagh/db8bcdb0adc06ff85a05 to your computer and use it in GitHub Desktop.
Reverse Camel Case implementation
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