Learning A* pathfinding with JavaScript