This lesson we're going to be checking to see who the winner is.
We've got the two rolls of the dice and we need to see which one is going to win and within the rules.
So the first item in the array, that can be the player we check to see if it actually equals the second
item within the array.
And if it does, then we're going to output that it's a draw.
So I also want to create a temp variable that's going to how is the message back to the user, the player.
So now we can update temp and we've got a few other conditions that we're going to look at.
So we've got else.
If so, we can do an elusive there.
And we're going to check to see if that one so that the first player is larger than the second one,
then we can say that player one wins.
And then lastly, and we only have one last condition, so we can just simply do else for this one.
We don't need to have any type of conditions there.
And in this case, we know that player two wins, let's output some of those values into our visible
area for the players so that we can see that, first of all, take output and update the inner HTML
with the contents of temp.
And I just want to do a quick update before we try that out.
I just realized that we need to do a quick update because Button was fine, that we got the core selector
with Button, but player one is an ID player too, as an ID and an output is an ID as well.
So we need to make sure the selectors are added in properly.
So now try that out.
Hit roll.
We see player two wins.
The score was four to six.
So player one got four.
Player two got six.
Let's try that out.
Player one wins in this case.
Player two wins and so on.
And also, let's add in the player.
So we've got Player one winner HTML so we can actually see the score that's being output and also add
in the score for player two.
So we've got four to two.
Player one wins three to six.
Player two wins.
It was a draw.
So both of them got three.
Player two wins and this one, so one to three and so on.
And the nice thing about it is it's fully dynamic.
So if you want to roll larger than six, you can do that as well.
And you can also update some of these conditions.
You can add in a score and a whole bunch of different functionality to really extend on this simple
application.
So go ahead and try it out for yourself.
And don't forget to update those selectors.
So we're selecting those objects properly.
So coming up next, we're going to extend on this and we're going to make it a little bit more visual
where we're going to output the dice rolling within the visual area here of our element.