Add A* algorithm in JS