Skip to content

Instantly share code, notes, and snippets.

@benjaminparnell
Created December 13, 2016 15:35
Show Gist options
  • Save benjaminparnell/cf1c3c05ddc391075365ef5b036dfac4 to your computer and use it in GitHub Desktop.
Save benjaminparnell/cf1c3c05ddc391075365ef5b036dfac4 to your computer and use it in GitHub Desktop.
var mlcm = require('mlcm')
, frac = require('frac')
module.exports = function getMultiplier (prizes) {
if (prizes.length === 0) return 0
if (Array.isArray(prizes) === false) throw new Error('getMultiplier requires an array')
return mlcm(prizes.map(function (prize) {
return frac(prize.chance, Infinity)[2]
}))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment