Created
September 20, 2018 22:36
-
-
Save LoganBarnett/3d0301b4a32ea253ca33ddde51df2d76 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// f is the function - it takes a single element of the array and returns a new element | |
function map(f, array) { | |
var newArray = [] | |
for(var i = 0; i < array.length; ++i) { | |
var oldItem = array[i] | |
var newItem = f(oldItem) | |
newArray.push(newItem) | |
} | |
return newArray | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment