I solved this statement but I feel that the code was very dirty… I would like to see if someone can code it in an optimized way to compare them and if not, how would I solve it?
/*
- Crea una función que analice una matriz 3×3 compuesta por “X” y “O”
- y retorne lo siguiente:
-
- “X” si han ganado las “X”
-
- “O” si han ganado los “O”
-
- “Empate” si ha habido un empate
-
- “Nulo” si la proporción de “X”, de “O”, o de la matriz no es correcta.
- O si han ganado los 2.
- Nota: La matriz puede no estar totalmente cubierta.
- Se podría representar con un vacío “”, por ejemplo.
*/
I tried with functions that validate rows, columns and diagonals, but I went through the list several times and too many ifs…
New contributor
damian lacava is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.