Skip to content

Instantly share code, notes, and snippets.

@brycetshaw
Last active September 10, 2021 16:26
Show Gist options
  • Save brycetshaw/5604e71c5b42f31517b631511b608ebd to your computer and use it in GitHub Desktop.
Save brycetshaw/5604e71c5b42f31517b631511b608ebd to your computer and use it in GitHub Desktop.
async function getTiesCountByNumberOfGoals(year, goals) {
const [gamesOnFirstPage, numberOfPages] = await getNumOfGamesFromPage(year, goals, 0);
const pageArray = Array.from(Array(numberOfPages).keys()).filter((e) => e !== 0);
return Promise.all(
[
gamesOnFirstPage,
...pageArray.map(page => getNumOfGamesFromPage(year, goals, page))
])
).then(data => data.reduce((x, y) => x + y, 0) || 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment