Building algorithms in Javascript as a learning exercise.