A markov chain implementation in JavaScript