Lastly we need to write the code that checks if a user has won the game and if they have we need to
display a message to Congress which right now we're not doing and we'll also probably hide the table.
So let's do it right here where we're setting the stage with the board the new board we're sitting has
one to be has one but right now we hardcoded it to be false every time we're saying you lose but let's
actually check in for us to know if a user has won.
We need to iterate and check every single cell here make sure that every single one is off meaning that
it's set to false and to do that we can't just loop once because we can loop over the rows.
And that would give us 1 2 3 4 5 but we then need to do our inner loop the same thing.
X and Y so that we can check all the values.
And I'm going to simplify it instead of doing a for loop or something.
I'm just gonna use every so board which is what we just changed we updated the board here before resetting
the state board dot every and then we can pass in for each row.
I'm going to do another row dot every and then for each cell and we just want to check that the cell
is false.
So we want this to be true theme meaning not false.
I know it's kind of a weird syntax but we do not sell to make sure this returns true.
So every cell in every row should be false.
Now let's see if it works.
This we need to make sure we're setting that to be the value of has one.
So let has one equal poor dot every.
Okay.
And then we save that.
Set it to the state.
It's going to be annoying to test so I'm gonna cheat a little bit and come into react here and change
some of these values and turn things on or off.
Okay.
I just toggled a couple of them on and off they're just off actually.
Now I should be able to click here and win the game and if we take a look in our state we should have
has one set to true.
So that part is working now we need to display something based off of that.
So instead of render we're not going to display the board at all.
If the user has one so instead of doing it down here I'm going to just circumvent the entire board and
up top do a short circuit.
So if this dot state DOT has one I'm going to just return right there with an H1 or style it in the
next video if you want to see how it had the neon effect and just say you won and that's it.
So if the user wins that's what we should see.
Not sure what color this text will show up as it will be an adventure.
Let's check it out.
So I'm going to do the same thing and cheat just a bit but instead of changing the board because we
already saw that that part was working.
If we update the board to be all off has one was set to false.
Now if I just toggle it to be true we're getting the text you want.
So our game is officially complete.
It's working.
I'm terrible at playing it so I can't verify using the real way of playing it.
I can only short circuited by changing the props in the next video.
I'll show you how to if you want how to style it the way that I did.
It's a little more colorful I guess.
Some neon effects but it has very little to do with react so you might just want to copy and paste the
style sheet from the solution and just see how it works.