I have a object like so:
{
"user1": 200,
"user2": 50,
"user3": 250,
"user4": 100
}
I would want to randomly pick one of these users based off of the value associated to their property. So in this scenario, user1 should have a 33.33% chance of winning, user2 should have 8.33% and so on. How could I do that?
Aucun commentaire:
Enregistrer un commentaire