So, we have:
1. An "Array" object, which represents a board with colors. Each cell of the array is a color number.
2. A "matchedCells" array, where each cell stores the coordinates of cells marked as "Matched".
Now, all that remains is to check for matches of 3+ colors vertically and horizontally. This is done using loops. Every time the color of the current cell matches the color of the previous cell, we add +1 to the local variable "n".
Here’s a visual example of how the function that finds matches of 3+ elements in the array works: