Skip to content

Instantly share code, notes, and snippets.

@knjname
Created April 27, 2021 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knjname/9953347f79c0e1c5e0b172928f2d7d20 to your computer and use it in GitHub Desktop.
Save knjname/9953347f79c0e1c5e0b172928f2d7d20 to your computer and use it in GitHub Desktop.
const stats = [... new Array(1000)].map(it => 0);
const makeStat = () => {
let result = 0;
for (let i = 0; i < 1000; i++) {
result += Math.random();
}
return result
}
for (let i = 0; i < 100000; i++) {
stats[Math.ceil(makeStat())]++;
}
for (let i = 0; i < stats.length; i++) {
if (stats[i])
document.write(`<div style="width: ${stats[i] / 4}px;">${i}</div>`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment