'How do I get a winning picture in a slide puzzle?

I make a slide puzzle game. When the puzzle is solved "won" should be displayed and the timer should stop.

I hope you can help me. Thanks.

Here is a link to the web editor for my puzzle link

Here is the part of the code but it doesn´t work:

function draw() {
  if (isSolved()) {
    console.log('SOLVED');
    timerValue = 0;
    text('Won', width/2, height/2);
  }   
}

function isSolved() {
  for (let i = 0; i < plate.length - 1; i++) {
    if (plate[i] !== tiles[i].index) {
      return false;
    }
  }
return true;
}


Solution 1:[1]

P5JS is saying that createImage() was expecting Integer for the second parameter, received number instead. This can be solved by changing let img = createImage(w, h); tp let img = createImage(int(w), int(h));.

I'm not entirely sure if this helps, because I don't know how your puzzle works (how it's solved) so please tell me if this doesn't work and I'll investigate further.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Voxel