Turing machine in JavaScript