Skip to content

Instantly share code, notes, and snippets.

@rmccullagh
Created October 22, 2014 19:51
Show Gist options
  • Save rmccullagh/fda7663312178ed78ed1 to your computer and use it in GitHub Desktop.
Save rmccullagh/fda7663312178ed78ed1 to your computer and use it in GitHub Desktop.
Reverse Camel Case implementation
{
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