learning algorithms in javascript from scratch