- You should have a set of values for Card.
Example:
const valuesOfCard = ['A','B','C','D', 'E', 'F']
- Based on difficulty of game create temporary array of values for game
| Difficulty | Elements in array |
|---|---|
| easy | 16(4x4) |
| medium | 36(6x6) |
| hard | 64(8x8) |
After this step you should have:
//for easy game
const cardsData = ['A','A','B','B','C','C','D','D','E','E','F','F','A','A','B','B']
- Than shuffle this array:
- Lodash shuffle
- Or use your custom implementation of shuffle algorithm. Example
- And the last step set values from
cardsDataarray to your fields array of arrays