Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created December 31, 2014 08: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 shigemk2/a4ec5b34a0e8c8f944c7 to your computer and use it in GitHub Desktop.
Save shigemk2/a4ec5b34a0e8c8f944c7 to your computer and use it in GitHub Desktop.
var math = 0;
var sum = 0;
var count = [0,0,0,0,0,0,
0,0,0,0,0,0,0];
for(var i = 0; i < 100; i++) {
math = 0;
for(var j = 0; j < 12; j++) {
math += Math.floor(Math.random(0, 1) * 10) / 10;
}
sum = Math.floor(math - 6);
count[Math.floor(sum + 6)] += 1;
}
var star = "";
for (var i = 0; i < count.length; i++) {
star = "";
for (var j = 0; j < count[i]; j++) {
star += "*";
}
console.log("%s: %s", i-6, star);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment