Algorithms written using javascript