different algorithms applied in javascript