Skip to content

Instantly share code, notes, and snippets.

@brycetshaw
Last active August 7, 2020 20:12
Show Gist options
  • Save brycetshaw/783d13a6df6b372e2335fa94cf12a630 to your computer and use it in GitHub Desktop.
Save brycetshaw/783d13a6df6b372e2335fa94cf12a630 to your computer and use it in GitHub Desktop.
maps integer array to promise array and resolves it to a single result
async function getNumDraws(year) {
const arrayOfScores = Array.from(Array(11).keys());
return Promise.all(arrayOfScores.map(item => getTiesCountByNumberOfGoals(year, item)))
.then(drawsCountForEachScore => {
return drawsCountForEachScore.reduce((x, y) => x + y, 0);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment