Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pfftdammitchris/fb92c314ac76ea670617014f40cab1ac to your computer and use it in GitHub Desktop.
Save pfftdammitchris/fb92c314ac76ea670617014f40cab1ac to your computer and use it in GitHub Desktop.
function map(arr, callback) {
const results = []
for (let index = 0; index < arr.length; index++) {
const item = arr[index]
// The promise ends up here. But this time we save the result inside our final collection that is being returned after the loop is finished
const result = callback(item)
results.push(result)
}
return results
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment