7-elephant

P43

Apr 30th, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // In Firefox, press Ctrl+Shift+K then copy, paste and run.
  2.  
  3. function encode(input)
  4. {
  5.     var output = "";
  6.    
  7.     for(var i = 0, length = input.length; i < length; i++)
  8.     {
  9.         var ch = input.charCodeAt(i);
  10.         var chNew = ch;
  11.        
  12.         if(ch >= 65 && ch <= 90)
  13.         {
  14.             chNew = 90 - ch + 65;
  15.         }
  16.         else if(ch >= 97 && ch <= 122)
  17.         {
  18.             chNew = 122 - ch + 97;
  19.         }
  20.         else if(ch >= 48 && ch <= 57)
  21.         {
  22.             chNew = 57 - ch + 48;
  23.         }
  24.         output += String.fromCharCode(chNew);
  25.     }
  26.    
  27.     return output;
  28. }
  29.  
  30. encode("AbCzZ 123409");
Advertisement
Add Comment
Please, Sign In to add comment