In this lesson, we're going to be updating the score.
So we've got the dealer and player both at zero and that's just the default start values.
So let's set a variable four score and this can be an array and can have two values in it.
So one will be the player and one will be the dealer.
And then we can use that to update the scoreboard.
So it's create a function in order to update the actual scoreboard of the gameplay.
And then we can call to this function whenever we need to make an update to whatever the scoreboard
score is.
So creating a function and we just call it score board doesn't have to pass on any values because again,
all of this stuff is global within the game object.
So using the game scoreboard and setting up the text content and we're going to this time well, let's
use a template literals.
So those are back tick's.
Those aren't quotes.
They're back text and they allow us to structure an ad in JavaScript.
There's more information about how a template literals work at the Budson.
Look, there's more information about how to help template literals work on them until a developer network.
And as you can see, these are back texts and they allow us to apply expressions directly within the
back ticks.
So regardless of having the single or double quotes.
This is slightly different.
And this is a great way to add in variables and values into strings without having to break out of the
string.
And it also accounts for taking in spaces and line breaks.
So it's a really good way to create templates for output of content.
And of course, if you want to, you can just use the regular quotes as well.
So I just want to introduce something a little bit different.
So dealer and introducing the expression, you do the dollar sign and the curly brackets.
And we're take the value of score with index of zero vs. the player.
And the player is going to also have a score and that's going to be contained within score index of
one and output.
So whatever we call it, scoreboard, it's going to update the scoreboard value.
And we can do that on the iron NITI as well.
And that updates the scoreboard values.
So it's taking it directly from whatever the score is.
So if we start out at score of one, you'll see it updates there within each team.
And that means that every time we need to make an update to the score, we can just call the scoreboard
object.
So going back into where we created the winner, we're going to update the winner values and where we've
got determining who the winner was.
So in this case, draw no winners.
In this case, the player is the winner.
So whichever one you want to use for the player, I'll use the second the one with the index of one
for player and just incremented.
And for the dealer internments score and incremented by one.
And then we'll watch the scoreboard object.
So this way it will track and see what the score is.
So player one because the dealer busted.
Let's steal it again.
Stant and dealer one.
Player one.
So everything is implemented now.
And actually we should say there was an error there that if we hit we see we we busted dealer wins with
14, but we still have the ability to keep hitting.
So we need to disable those buttons.
So there are a number of different bugs that you're going to find.
And that's why it's important to be able to play through the game and just make sure that you're not
encountering any of these bugs.
So we do need to when we are checking the winner, we do need to turn those off.
So let's update and we'll turn them off.
And that's turning off the buttons for the hit and for the stand.
So let's try that one more time.
So since we're working a bit better, some means next.
Coming up, we can account for the betting, so we'll add in some betting and wagering into the gameplay.
So it's still to come in the next lesson.
So go ahead and play through your project, make sure that everything is working as expected, that
the count is working properly and that you're able to determine the winner and that the buttons and
the next actions that user is expected to take are available to the user as they play through the game.