weighted-arrays
install it
npm i weighted-arrays
use it
const wa = const array = value: 'a' weight: 0 value: 'b' weight: 25 value: 'c' weight: 10const getWeight = objweight const random = wa// output: sometimes { value: 'b', weight: 2.5}, sometimes { value: 'c', weight: 10}, and never { value: 'a', weight: 0} const probability = wa// output: 0.2