1
00:00:00,450 --> 00:00:06,780
Almost there, we've almost completed this mini application, we've got the logic where we've got the

2
00:00:06,780 --> 00:00:12,270
computer being selected, making a selection at random, we've got the player to be able to make a selection.

3
00:00:12,450 --> 00:00:16,140
We've got our ability to check who won that particular round.

4
00:00:16,290 --> 00:00:21,920
And now it's just a matter of putting that information to the player as well as updating the score.

5
00:00:22,320 --> 00:00:23,750
So we need some more conditions.

6
00:00:23,760 --> 00:00:28,560
We've got quite a few conditions going on in this game, and that's usually the likely scenario for

7
00:00:28,590 --> 00:00:29,540
most games.

8
00:00:29,550 --> 00:00:32,130
Where are you going to have a lot of conditions that are being met?

9
00:00:32,400 --> 00:00:37,740
So we're going to check to see if the winner is a player, Arizona state player.

10
00:00:38,920 --> 00:00:47,530
Plus equals and this is so we can output that value to the player, so we're going to do result plus

11
00:00:47,950 --> 00:00:52,210
result and wins and I'll show you how we're going to use that information.

12
00:00:53,230 --> 00:00:56,490
And we can also update the value of winner.

13
00:00:57,460 --> 00:00:59,760
And we also need a way to keep score.

14
00:01:00,070 --> 00:01:05,970
So I'm going to set up an array and both of them are going to start out with zero.

15
00:01:06,280 --> 00:01:07,810
So this is how we're going to keep score.

16
00:01:07,960 --> 00:01:11,710
So the first one will be the player, the second one will be the computer.

17
00:01:11,710 --> 00:01:14,050
So winner zero.

18
00:01:14,650 --> 00:01:18,700
And we're going to increment the value of winner zero next.

19
00:01:18,760 --> 00:01:26,680
Check to see if result is equal to computer because remember, we are returning back either player computer

20
00:01:26,680 --> 00:01:30,030
or draw as a result when we're checking the winner.

21
00:01:30,340 --> 00:01:34,770
And if it is computer, then we're going to see computer wins.

22
00:01:35,140 --> 00:01:41,230
So result wins the same format and then we're going to increment winner number two by one.

23
00:01:41,530 --> 00:01:44,470
So this is going to give us the ability to output and update the score.

24
00:01:45,100 --> 00:01:47,920
And we have score within the score object.

25
00:01:48,460 --> 00:01:56,290
So taking that score in our HTML, we have player one and we can bracket out that score value there.

26
00:01:56,920 --> 00:02:00,130
And then player two and also do the same thing.

27
00:02:00,460 --> 00:02:03,100
Where are we going to bracket whatever the value of the score is?

28
00:02:03,310 --> 00:02:04,390
It would close that off.

29
00:02:04,630 --> 00:02:07,590
And then next, let's just add that in with JavaScript.

30
00:02:07,930 --> 00:02:15,130
So we're going to add in winner the first item within that array and then add in the second item from

31
00:02:15,130 --> 00:02:15,650
that array.

32
00:02:16,090 --> 00:02:18,400
So saving that, let's try that out.

33
00:02:18,670 --> 00:02:22,060
And now when we click it, we see the player wins.

34
00:02:22,070 --> 00:02:25,450
So the player scored one, the player scored two.

35
00:02:25,930 --> 00:02:26,920
It was a draw.

36
00:02:27,250 --> 00:02:30,880
Player scored three, player scored four five.

37
00:02:31,210 --> 00:02:35,080
And it's another draw and player scored again.

38
00:02:35,080 --> 00:02:39,930
So lucky player around this time and this time the computer scored.

39
00:02:40,150 --> 00:02:45,940
So it's always worth while taking the time just to make sure that your gameplay is working as expected.

40
00:02:46,180 --> 00:02:47,710
And in this case it is.

41
00:02:47,890 --> 00:02:49,900
So everything is working well.

42
00:02:50,080 --> 00:02:53,290
You can also update this and make it look a whole lot better.

43
00:02:53,440 --> 00:02:58,840
And the last thing that we want it to do is output a message to the user and we're going to create a

44
00:02:58,840 --> 00:03:01,720
function in order to do that in the upcoming lesson.

45
00:03:01,960 --> 00:03:03,010
So that's still to come.

46
00:03:03,190 --> 00:03:06,820
Go ahead and add updating of the inner HTML.

47
00:03:06,940 --> 00:03:14,170
So manipulating the element with score a class of score in it, which we've selected as a score object

48
00:03:14,170 --> 00:03:17,050
in the earlier lessons and update that score.

49
00:03:17,050 --> 00:03:21,460
So output the score values so that everyone can see what the score is.
