Skip to content

Instantly share code, notes, and snippets.

@LoganBarnett
Created September 20, 2018 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LoganBarnett/3d0301b4a32ea253ca33ddde51df2d76 to your computer and use it in GitHub Desktop.
Save LoganBarnett/3d0301b4a32ea253ca33ddde51df2d76 to your computer and use it in GitHub Desktop.
// 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