Skip to content

Instantly share code, notes, and snippets.

View mirojones's full-sized avatar
🇵🇸

Miro mirojones

🇵🇸
View GitHub Profile
@alesmenzel
alesmenzel / pick-random-element-based-on-probability.js
Last active July 25, 2025 05:22
Select random element from array by probability
const arr = ['A', 'B', 'C'];
// Probability map
const weight = {
A: 0.5,
B: 0.3,
C: 0.2
};
const find = input =>