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

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -