Turing machine implementation in JavaScript