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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -