javascript - How can I use .charCodeAt on an array? -


i know can use apply method, i'm having trouble understanding how use it, namely goes parenthesis. i've tried reading articles on , watching yt videos, end still feeling confused.

what i'm trying here convert following string unicode using charcodeat, have add 13 each value because i'm using rot13 cipher. after plan use fromcharcode return numerical values letters message, , use .join full message.

function rot13(str) {    var strsplit = str.split('');   strsplit.charcodeat.apply();  }   rot13("serr pbqr pnzc"); 

use array functions:

function rot13(str) {   var strsplit = str.split('');   var res = strsplit.map(l => l.charcodeat())   return res; }   console.log(rot13("serr pbqr pnzc")); 

you may want concat numbers string:

console.log(rot13("serr pbqr pnzc").map(l => json.stringify(l)).join("")) 

however, may have caveats...


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -