javascript - charCodeAt() inside map function returning original array -


i have following;

function rot13(str) {   var result = str.split("");   result.map(function(val) {     return val.charcodeat();    }); } rot13("serr pbqr pnzc"); 

when run returned array same input array

["s", "e", "r", "r", " ", "p", "b", "q", "r", " ", "p", "n", "z", "c"] 

could me understand why isn't working?

array.map creates new array , not mutate original array, have return explicitly or assign variable:

function rot13(str) {   var result = str.split("");  return result.map(function(val) {    return val.charcodeat();   }); } 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -