I have successfully created a sliding puzzle with various formats, including 3x3, 3x4, 4x3, and 4x4. When you run my code, you will notice a selection box on the right side where you can choose from these four formats. The sliding puzzle is almost complete. However, I am in need of a function that can check after each move if the puzzle has been solved. If it has, I would like it to display a message such as "Congratulations! You solved it!" or "You won!". Do you have any ideas on how I can implement this feature?
In the javascript code, you will see that the first function, loadFunc(), is used to replace every piece with a blank one. The subsequent functions are responsible for selecting and changing the format, shifting puzzle pieces into the blank space, and shuffling the pieces' positions randomly. If you have any questions or encounter any difficulties understanding the code, please feel free to ask in the comments. Thank you in advance.
As my reputation is limited, I will provide a link to the images here: https://i.sstatic.net/9fIyk.jpg. These images are currently being used as placeholders.
Here is the jsfiddle:
http://jsfiddle.net/Cuttingtheaces/vkyxgwo6/19/