Connect-4 Solver
Implement the famous game in JavaScript
We'll cover the following...
We'll cover the following...
Suppose an 8*6 Connect-Four table is given. Each cell of the table is either empty (null), or contains the player’s number from the possible values 1 and 2. Determine if any player has won the game by connecting four of their symbols horizontally or vertically. For simplicity, ignore diagonal matches.
Solution:
As there is no example data, we have to model the table ourselves.
This simple arrow function returns an empty 6*8 array:
It is evident that we will need a function that checks all elements of the array for four consecutive matches. I encourage you to implement this function yourself. Reading my ...