Reputation: 1698
Question Summary
From this SO question I am aware of Math.random()
. However, is there a way to increase the chance of a certain number in being chosen?
Situation
Problem I can assign a number for each player and do Math.random from 1 to 10, but say player 2 has earned another entry. How do I make number 2 get a better chance of winning?
Notes for possible duplicate claims I am aware of this question closely trying to do the same. However, I am in need of a pure Javascript solution (since this has to be in client side) using Math.random() or other functions you may suggest. Also, this is an entry based random and not a by percent(%) chance.
Upvotes: 0
Views: 348
Reputation: 651
Have each user assigned an array of ticket numbers stored in a property. When a user earns another ticket, just append it to the ticket numbers array property for them. This would generate the statistical result you want.
Upvotes: 1