Welcome to SOe!
Matrices are usually two-dimensional, like the one you describe.
Going through a matrix is simple, the for loops are like this:
for(let i=0; i < cantidadFilas; i++){ *
for(let j=0; j < cantidadElementosXFila; j++){ **
//aquí insertas tu imagen aleatoria
}
}
* Where the number of rows is 7 in your case, this loop will jump only from row to row, over the 7 rows, without entering each of its elements
** This loop will go through each iteration of the top loop, all the elements of the row in which it is, at that moment, for example when i = 0, it will be the iteration on the first row, being this second loop will travel your 7 elements (when j = 0, your 1st element, when j = 1, your second element, and so on).
NOTE : The notation of the asterisks is only used to refer to the explanation of each loop and contribute to the cleaning of the code used as an example, you should not include it in your code.
You have a nice source of information to delve into a for loop here: MDN : Mozilla Developer Community
Feel free to participate and ask in this community as well as contribute to it whenever you want, respecting the clear rules.