This is a small hack that I created over the weekend. I learnt about the Monte Carlo method while doing Princeton's Functional Programming course[0] in OCaml[1] as one of the assignment problems. To get the first four digits consistently, I ran around 200,000 - 400,000 simulations - not quite possible in the browser!
[0] - http://www.cs.princeton.edu/~dpw/courses/cos326-12/
[1] - https://github.com/prakhar1989/ocaml-experiments/blob/master...