This is a simple project for randomizing, almost like a lottery.
The algorithm for randomizing is as follows:
// Get random number with max
const getRandomNumber = (max: number) => Math.floor(Math.random() * max);
// Loop for ordering input <names>
let unrandomized = [...names];
let randomized = [];
while (unrandomized.length > 0) {
let nextIndex = getRandomNumber(unrandomized.length);
let pickedItem = unrandomized.splice(nextIndex, 1);
randomized.push(pickedItem[0]);
}
To set up this project locally:
git clone https://github.com/andreassjoberg/really-simple-randomizer
cd really-simple-randomizer
npm install
npm run dev