A* Algorithm implemented by Javascript