How do you write the Viterbi algorithm in JavaScript?