Last active
August 29, 2015 14:21
-
-
Save ronnieoverby/baa9639f6ff39c041d6e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var n = 1234; | |
var array = map(n.toString().split(''), parseInt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function map(array, mapper){ | |
var newArray = []; | |
for(var i = 0; i < array.length; i++){ | |
var item = array[i]; | |
var newItem = mapper(item); | |
newArray[i] = newItem; | |
} | |
return newArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment