1.0.1 • Published 5 years ago
random-with-percentage v1.0.1
random-percentage
Disclaimer: this package is in alpha. Please report any bugs to me (preferably on discord, my id is 316226442721755137)
How to use:
const random_percentage = require("random-with-percentage");
const randomArray = [{
"name": "10 percent chances",
"chance": 10
},
{
"name": "20 percent chances",
"chance": 20
},
{
"name": "70 percent chances",
"chance": 70
}]
//chances must sum up to 100
random_percentage(randomArray).then(result => console.log(result))
//"10 percent chances" OR "20 percent chances" OR "70 percent chances"