Implementation of the A* Algorithm in Javascript