Naive Bayes JavaScript hack