Hacker News new | ask | show | jobs
by mattmanser 4468 days ago
I think making it an object has made the code unnecessarily complicated. I think you could almost 1/2 code with a simple function.

This is where I personally think javascript programming is going wrong at the moment, so much boiler plate.

You're also programming a bit too defensively. Ask yourself, do you honestly need all those checks? What would actually happen if you got rid of the checks? I think your code would be clearer without them and the programmer would still realize he'd made a mistake and passed in nulls.

1 comments

Thanks for the feedback!

Confidence.js comes from how we operate on A/B tests at sendwithus - we think of them as variants associated with results. While the code could definitely boil down to a few simple math functions, we find objects to be a good way to organize our data models.

Also, "getRequiredSampleSize" is called twice for each variant - in the "getResult"'s loop and then inside "hasEnoughData". Same thing for "getVariant". Would you welcome a pull request?

Your project is great, I'd totally use at work. Also, it was to learn the math behind that. Thanks!

Glad you like it, happy to have you contribute :)