Trying to Make an Alphabetical Converter With JavaScript Arrays -
i'm trying create alternative "languages" roleplaying game administer. it's simple character substitution, although in places 1 character can replaced multiple. how can javascript arrays?
some examples:
elemental
a b c d e f g h j k l m n o p q r s t u v w x y z r n y f z d u h g t e q b w m v o k l x j c s p b c d e f g h j k l m n o p q r s t u v w x y z r n y f z d u h g t e q b w m v o k l x j c s porcish
a b c d e f g h j k l m n o p q r s t u v w x y z c w r p o d y e b x g k z h q v u s m l j f n t b c d e f g h j k l m n o p q r s t u v w x y z c w r p o d y e b x g k z h q v u s m l j f n tmagi's tongue
a b c d e f g h j k l m n o p q r s t u v w x y z coa taj nel sa jo yin p g d w m hep qoi uxo lso bei ilok abi zel rol kef fas oel ero ve xo b c d e f g h j k l m n o p q r s t u v w x y z coa taj nel sa jo yin p g d w m hep qoi uxo lso bei ilok abi zel rol kef fas oel ero ve xo
try
<script type="text/javascript"> var lang = { normal : { 'a':0, 'b':1, 'c':2, 'd':3}, elemental : ['r','n','a','y'], orkish : ['c','w','r','p'], magis : ['coa','taj','nel','sa'] }; console.log('normal : bbc'); var _str = 'bbc'; var translate = ''; for(i = 0; <= _str.length - 1;i++) { var t = _str[i]; translate += lang['elemental'][lang['normal'][t]]; } console.log(translate); var translate = ''; for(i = 0; <= _str.length - 1;i++) { var t = _str[i]; translate += lang['magis'][lang['normal'][t]]; } console.log(translate); </script> result in browser console (for example chrome - f12) :
normal : bbc
elemental : nna
magis : tajtajnel
Comments
Post a Comment