8 Puzzle Problem Javascript