Share your repls and programming experiences

← Back to all posts
Flip a Coin 10000 Times!
STCollier

This program will flip a coin as many times as your computer can handle and tell you how many times you get heads or tails.

Edit: lol how did this lame program get 7 13 up-votes

Edit 2: Y'all made me self conscious about my code so I updated it, making the program better.

Edit 3: Also, please don't crucify me, I'm too lazy to style the program.

Also, as @TheDrone7 mentioned, the results are somewhat biased, because the JavaScript Math.random function is given a seed such that the random number is almost always going to be very near to 0.5. So sorry about that, I couldn't think of a way to fix it.

Voters
HongweiChen
RileyMears
ADEAR
YilingSun
hySp
james278
Yoplayer1py
ch1ck3n
sojs
STCollier
Comments
hotnewtop
InvisibleOne


Cool

TheDrone7

Fun fact, the js Math random function is given a seed such that the random number is almost always going to be very near to 0.5

Yoplayer1py

Cool

STCollier

@Yoplayer1py Thanks!

CoderGautamYT

This is so simple and so interesting lol

STCollier

@CoderGautamYT thank you :)

sn236

Nice, I've made some changes - https://coin-flipping-statistics.sn236.repl.co/. (As it was plain)

sojs

@sn236 @STCollier I made one as well. This one has a couple new things.
1. You really overcomplicated the code... it wont go higher than 10K. I made it go all the way up as high as you want (I have it currently set at 100 Million... no higher bc of lag). I also added a stylesheet. Mine also calculates the ratio of heads to tails to make it easily readable how close it is to even.

STCollier

@sojs Thanks for the tips!! I'll check out your code to see what I should do differently. Also, I wrote this program before I even knew about for loops, so the looping system is just a weird copy from stack overflow.

sojs

ya. loops are a lot better because you can go through them as many times as you want. @STCollier