A tic tac toe game's board has 9 squares. "They" basically are the three squares you want to check so that you can declare the winner if the condition is fulfilled.
Can you write an if-statement to check if the three squares I am referring to are equal?
If the three squares are all equal, they can be ("X"), or ("O"), or asterisks ("*"). But you only need to check one of them. Just one of them being a ("X") or ("O") and you will be able to find the winner.
> That makes sense now, but wouldn't this be an issue with two players without an else statement?
There is absolutely no else statement in the declareWinner() function. It is just for the sake of being as simple as possible.
Anyway, can you use all what I have said to make a complete if-statement yourself?
if (ticTac[0][0]==ticTac[0][1] && ticTac[0][0]==ticTac[0][2])
No, that is still not complete.
Let me repeat : This if-statement only checks if the three squares are equal generally, but you still do not know whether they can actually be ("X"), or ("O"), or asterisk ("*"). You cannot let this if-statement pass if they are ("*"), because the winner can't be an asterisk. Thus an additional checking is required.
if (ticTac[0][0]==ticTac[0][1] && ticTac[0][0]==ticTac[0][2] && ticTac[0][0]!="*")
> If the three squares are all equal, they can be ("X"), or ("O"), or asterisks ("*"). But you only need to check one of them. Just one of them being a ("X") or ("O") and you will be able to find the winner.
"One of them" mean you check one of the the three squares : ticTac[0][0], ticTac[0][1] or ticTac[0][2]