1
00:00:00,300 --> 00:00:03,360
This lesson we're going to be checking to see who the winner is.

2
00:00:03,420 --> 00:00:10,130
We've got the two rolls of the dice and we need to see which one is going to win and within the rules.

3
00:00:11,850 --> 00:00:18,600
So the first item in the array, that can be the player we check to see if it actually equals the second

4
00:00:18,600 --> 00:00:19,860
item within the array.

5
00:00:20,040 --> 00:00:23,140
And if it does, then we're going to output that it's a draw.

6
00:00:23,490 --> 00:00:32,330
So I also want to create a temp variable that's going to how is the message back to the user, the player.

7
00:00:33,000 --> 00:00:38,330
So now we can update temp and we've got a few other conditions that we're going to look at.

8
00:00:39,030 --> 00:00:40,380
So we've got else.

9
00:00:40,380 --> 00:00:42,270
If so, we can do an elusive there.

10
00:00:42,540 --> 00:00:49,920
And we're going to check to see if that one so that the first player is larger than the second one,

11
00:00:50,220 --> 00:00:52,620
then we can say that player one wins.

12
00:00:53,280 --> 00:01:00,210
And then lastly, and we only have one last condition, so we can just simply do else for this one.

13
00:01:00,240 --> 00:01:02,640
We don't need to have any type of conditions there.

14
00:01:04,260 --> 00:01:12,930
And in this case, we know that player two wins, let's output some of those values into our visible

15
00:01:12,930 --> 00:01:18,240
area for the players so that we can see that, first of all, take output and update the inner HTML

16
00:01:18,450 --> 00:01:20,160
with the contents of temp.

17
00:01:20,430 --> 00:01:23,920
And I just want to do a quick update before we try that out.

18
00:01:23,940 --> 00:01:29,580
I just realized that we need to do a quick update because Button was fine, that we got the core selector

19
00:01:29,580 --> 00:01:35,730
with Button, but player one is an ID player too, as an ID and an output is an ID as well.

20
00:01:35,920 --> 00:01:39,330
So we need to make sure the selectors are added in properly.

21
00:01:39,360 --> 00:01:40,410
So now try that out.

22
00:01:40,410 --> 00:01:41,070
Hit roll.

23
00:01:41,190 --> 00:01:43,050
We see player two wins.

24
00:01:43,290 --> 00:01:46,380
The score was four to six.

25
00:01:46,650 --> 00:01:48,330
So player one got four.

26
00:01:48,360 --> 00:01:49,650
Player two got six.

27
00:01:49,800 --> 00:01:50,670
Let's try that out.

28
00:01:50,820 --> 00:01:52,250
Player one wins in this case.

29
00:01:52,530 --> 00:01:54,180
Player two wins and so on.

30
00:01:54,510 --> 00:01:57,270
And also, let's add in the player.

31
00:01:57,870 --> 00:02:04,950
So we've got Player one winner HTML so we can actually see the score that's being output and also add

32
00:02:04,950 --> 00:02:06,900
in the score for player two.

33
00:02:07,290 --> 00:02:08,730
So we've got four to two.

34
00:02:08,730 --> 00:02:11,040
Player one wins three to six.

35
00:02:11,040 --> 00:02:12,000
Player two wins.

36
00:02:12,600 --> 00:02:13,490
It was a draw.

37
00:02:13,500 --> 00:02:14,730
So both of them got three.

38
00:02:14,970 --> 00:02:18,420
Player two wins and this one, so one to three and so on.

39
00:02:18,600 --> 00:02:21,180
And the nice thing about it is it's fully dynamic.

40
00:02:21,360 --> 00:02:24,660
So if you want to roll larger than six, you can do that as well.

41
00:02:24,960 --> 00:02:27,930
And you can also update some of these conditions.

42
00:02:27,930 --> 00:02:33,540
You can add in a score and a whole bunch of different functionality to really extend on this simple

43
00:02:33,540 --> 00:02:34,230
application.

44
00:02:34,530 --> 00:02:36,090
So go ahead and try it out for yourself.

45
00:02:36,300 --> 00:02:38,730
And don't forget to update those selectors.

46
00:02:38,850 --> 00:02:41,070
So we're selecting those objects properly.

47
00:02:42,330 --> 00:02:46,710
So coming up next, we're going to extend on this and we're going to make it a little bit more visual

48
00:02:46,860 --> 00:02:53,100
where we're going to output the dice rolling within the visual area here of our element.
