JavaScript: Comparison Snakes and Visvalingam