This lesson, we're going to be wrapping up our application and we need a way for the player to be able
to make a guess of the scrambled word.
So let's go through our application quickly.
We start we're presented with a scrambled word, and now it's up to the player to guess what that word
is.
And once the player types in the word, we want them to be able to hit guess and have that checked to
see if the word is the actual one that we've selected.
And that's where we've got the else.
So if the inplay is already started that we don't need to generate any more words and we're going to
let the player guess whatever the word is, remember, we've got this store globally, whatever the
word value is that we want it to output and we just need to check to see if it matches.
So selecting our elements, we'll take our temp guess value.
And this is the value that's contained within the input we've already got the input under the query
selector.
Guess so we can take that object guess and select the value of guess and all console logged out for
now.
So tenth guess so that we can see and make sure that we're actually picking up that value.
So type and test we see that we've got test there.
So now it's just a matter of typing in a condition to check to see the temp guess is equal to and we
can use an absolute equal to such a three equal signs there.
And that also checks the type because both of them are going to be strings.
So we're checking to see if they're actually equivalent.
And if they are, then we're going to type in the console.
Correct.
And if they're not, then we've got an else statement and they need to guess again and we'll say yes
again.
So let's try that out.
So now we start and we don't we're going to hide this eventually so we don't know what the word is.
But during testing, I usually like to have that value there.
And we can see that we've got guess again, we've got correct.
So when we do get the correct answer, we see that we are returning back.
Correct.
So that should lead us to actually to have another option.
And that's going to be to start the inplay once again.
So let's update that.
And if we did get it correct, we can update that and we can also update the message to the player so
the inner HTML can be correct.
It was.
And also we'll output that scrambled word there and we'll also let the player start again.
So what we did over here, we're just going to do the opposite.
So start and we're going to simply toggle this value.
Let's try that again.
And this time, if we get it right and I was so hoping to get to Mellissa document, I just got to copy
and paste that and guess so.
Correct.
It was document.
We can start it again.
So there's another word and guess that again, I'm going to add in a little bit of styling so that we
can have some spacing between these words and we can also output that font size to be quite a bit larger.
So where it's actually font size and I'm going to make it to m also adding in a margin at the bottom.
So we've got some spacing.
Try that out as our guests and let's do website.
So guess it and correct it was website start again.
You can also score the number of tries and turns that it takes so you can have that as a global variable
and started out to equal zero.
And then every time we start the game we're going to restart that value to zero.
And then every time we take a guess, we can increment score and then add to the statement guesses.
Let's try that one more time.
So now we know its website, but let's say let's do a few temporary guesses.
So website and correct.
It was website.
It took two guesses at in a space there.
So that's essentially our quick game in order for a guessing game and again, once again, fully dynamic.
So even if you add in new content here, so let's add in the word new, it's going to be dynamic and
it's not going to fail.
We see that we get all of those elements generated out and eventually we're also going to get new as
well.
And so we see that we also get that new value that we just added in.