Skip to content

Instantly share code, notes, and snippets.

@herminiotorres
Last active August 30, 2023 12:41
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 herminiotorres/5573dbb143e8e8b3e9654f518e1d005a to your computer and use it in GitHub Desktop.
Save herminiotorres/5573dbb143e8e8b3e9654f518e1d005a to your computer and use it in GitHub Desktop.
Script to get the winner number
const luckyNumber = Number(
document.querySelector('.thismonthsnumber').textContent
);
const winnerNumber = Array.from(
document.querySelectorAll(
'.thismonthsentriestable tr td:first-child'
)
)
.map((element) => {
const number = Number(element.textContent);
const rest =
number >= luckyNumber ?
number - luckyNumber :
luckyNumber - number;
return [number, rest];
})
.sort(([, a], [, b]) => a - b)
.slice(0,2);
console.table(winnerNumber);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment