Let's now imagine holding a real deck in our hand and setting up the matching game.
We first shuffle the cards in our hand and then we put each card on the table with the back facing up. For easier game play, we align the cards into a 4x3 array. Now the game is set up.
Now we are going to play the game. We pick up one card and flip it to make it face up. We pick another one and face it upwards. Afterwards, we have two possible actions. We take away those two cards if they are in the same pattern. Otherwise, we put it back facing down again, as if we have not touched them. The game continues until we pair all cards and take them all.
The code flow will be much more clear after we have the step-by-step scenario in our mind. Actually, the code in this example is exactly the same as the procedure we play with a real deck. We just need to replace the human language into the JavaScript code.