1
00:00:00,830 --> 00:00:03,400
In this lesson, we're going to be updating the score.

2
00:00:03,510 --> 00:00:09,840
So we've got the dealer and player both at zero and that's just the default start values.

3
00:00:10,170 --> 00:00:16,230
So let's set a variable four score and this can be an array and can have two values in it.

4
00:00:16,530 --> 00:00:19,530
So one will be the player and one will be the dealer.

5
00:00:20,070 --> 00:00:22,740
And then we can use that to update the scoreboard.

6
00:00:22,990 --> 00:00:28,360
So it's create a function in order to update the actual scoreboard of the gameplay.

7
00:00:28,770 --> 00:00:33,390
And then we can call to this function whenever we need to make an update to whatever the scoreboard

8
00:00:33,450 --> 00:00:34,410
score is.

9
00:00:34,740 --> 00:00:42,090
So creating a function and we just call it score board doesn't have to pass on any values because again,

10
00:00:42,090 --> 00:00:45,090
all of this stuff is global within the game object.

11
00:00:45,450 --> 00:00:53,160
So using the game scoreboard and setting up the text content and we're going to this time well, let's

12
00:00:53,160 --> 00:00:54,300
use a template literals.

13
00:00:54,310 --> 00:00:55,500
So those are back tick's.

14
00:00:55,770 --> 00:00:56,600
Those aren't quotes.

15
00:00:56,610 --> 00:01:00,660
They're back text and they allow us to structure an ad in JavaScript.

16
00:01:00,840 --> 00:01:05,460
There's more information about how a template literals work at the Budson.

17
00:01:05,460 --> 00:01:10,140
Look, there's more information about how to help template literals work on them until a developer network.

18
00:01:10,530 --> 00:01:15,870
And as you can see, these are back texts and they allow us to apply expressions directly within the

19
00:01:15,870 --> 00:01:16,490
back ticks.

20
00:01:16,710 --> 00:01:20,160
So regardless of having the single or double quotes.

21
00:01:20,580 --> 00:01:21,840
This is slightly different.

22
00:01:22,180 --> 00:01:27,750
And this is a great way to add in variables and values into strings without having to break out of the

23
00:01:27,750 --> 00:01:28,110
string.

24
00:01:28,350 --> 00:01:32,100
And it also accounts for taking in spaces and line breaks.

25
00:01:32,340 --> 00:01:36,300
So it's a really good way to create templates for output of content.

26
00:01:36,750 --> 00:01:40,830
And of course, if you want to, you can just use the regular quotes as well.

27
00:01:40,980 --> 00:01:43,170
So I just want to introduce something a little bit different.

28
00:01:43,590 --> 00:01:50,070
So dealer and introducing the expression, you do the dollar sign and the curly brackets.

29
00:01:50,220 --> 00:01:56,460
And we're take the value of score with index of zero vs. the player.

30
00:01:56,940 --> 00:02:03,630
And the player is going to also have a score and that's going to be contained within score index of

31
00:02:03,690 --> 00:02:05,130
one and output.

32
00:02:05,160 --> 00:02:09,610
So whatever we call it, scoreboard, it's going to update the scoreboard value.

33
00:02:09,990 --> 00:02:12,810
And we can do that on the iron NITI as well.

34
00:02:13,020 --> 00:02:15,510
And that updates the scoreboard values.

35
00:02:15,690 --> 00:02:18,090
So it's taking it directly from whatever the score is.

36
00:02:18,390 --> 00:02:23,130
So if we start out at score of one, you'll see it updates there within each team.

37
00:02:23,640 --> 00:02:29,100
And that means that every time we need to make an update to the score, we can just call the scoreboard

38
00:02:29,190 --> 00:02:29,610
object.

39
00:02:29,910 --> 00:02:37,830
So going back into where we created the winner, we're going to update the winner values and where we've

40
00:02:37,830 --> 00:02:39,840
got determining who the winner was.

41
00:02:40,140 --> 00:02:42,270
So in this case, draw no winners.

42
00:02:42,600 --> 00:02:44,700
In this case, the player is the winner.

43
00:02:45,060 --> 00:02:51,420
So whichever one you want to use for the player, I'll use the second the one with the index of one

44
00:02:51,840 --> 00:02:53,790
for player and just incremented.

45
00:02:54,150 --> 00:02:58,750
And for the dealer internments score and incremented by one.

46
00:02:59,130 --> 00:03:01,560
And then we'll watch the scoreboard object.

47
00:03:01,830 --> 00:03:05,760
So this way it will track and see what the score is.

48
00:03:06,360 --> 00:03:08,640
So player one because the dealer busted.

49
00:03:08,880 --> 00:03:09,750
Let's steal it again.

50
00:03:10,590 --> 00:03:12,750
Stant and dealer one.

51
00:03:12,750 --> 00:03:13,570
Player one.

52
00:03:13,980 --> 00:03:15,940
So everything is implemented now.

53
00:03:16,110 --> 00:03:24,180
And actually we should say there was an error there that if we hit we see we we busted dealer wins with

54
00:03:24,260 --> 00:03:27,510
14, but we still have the ability to keep hitting.

55
00:03:27,720 --> 00:03:30,000
So we need to disable those buttons.

56
00:03:30,240 --> 00:03:32,700
So there are a number of different bugs that you're going to find.

57
00:03:32,970 --> 00:03:36,810
And that's why it's important to be able to play through the game and just make sure that you're not

58
00:03:37,110 --> 00:03:38,850
encountering any of these bugs.

59
00:03:39,120 --> 00:03:44,520
So we do need to when we are checking the winner, we do need to turn those off.

60
00:03:44,610 --> 00:03:47,010
So let's update and we'll turn them off.

61
00:03:47,130 --> 00:03:51,750
And that's turning off the buttons for the hit and for the stand.

62
00:03:51,990 --> 00:03:53,340
So let's try that one more time.

63
00:03:53,640 --> 00:03:56,720
So since we're working a bit better, some means next.

64
00:03:57,090 --> 00:04:04,770
Coming up, we can account for the betting, so we'll add in some betting and wagering into the gameplay.

65
00:04:05,010 --> 00:04:06,660
So it's still to come in the next lesson.

66
00:04:06,990 --> 00:04:12,750
So go ahead and play through your project, make sure that everything is working as expected, that

67
00:04:12,810 --> 00:04:18,420
the count is working properly and that you're able to determine the winner and that the buttons and

68
00:04:18,420 --> 00:04:24,310
the next actions that user is expected to take are available to the user as they play through the game.
