javscript Maze Solver