Javascript version of the Dawkins' Weasel algorithm, tested with QUnit.