Now that I have a better understanding of the requirements, you can simply create a character map for such notes:
Example: http://jsfiddle.net/gaG28/2/
var charMap = { a:'z',b:'v',c:'n',d:'s',e:'d', f:'k',g:'e',h:'y',i:'j',j:'r', k:'f',l:'m',m:'a',n:'c',o:'q', p:'t',q:'g',r:'i',s:'b',t:'p', u:'l',v:'u',w:'h',x:'o',y:'w',z:'x' }; var str = "abcdefghijklmnopqrstuvwxyz"; var str_array = str.split(''); for( var i = 0, len = str_array.length; i < len; i++ ) { str_array[ i ] = charMap[ str_array[ i ] ] || str_array[ i ]; } str = str_array.join('');
It will also leave any characters that are not found on the map.
source share