JavaScript version of estimating pi.