Algorithms written in javascript