Skip to content

Instantly share code, notes, and snippets.

@mattmazzola
Created November 23, 2020 03:51
Show Gist options
  • Save mattmazzola/c2af7ba5307a2e9ab879ef927f116f5d to your computer and use it in GitHub Desktop.
Save mattmazzola/c2af7ba5307a2e9ab879ef927f116f5d to your computer and use it in GitHub Desktop.
Get question within range
const minRating = player.rating - ratingRange
const maxRating = player.rating + ratingRange
const isRatingWithinRange = (question: Question) => minRating <= question.rating && question.rating <= maxRating
const question = getRandomWhichMeetsConstraints(questions, isRatingWithinRange)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment