This lesson, we're going to complete our typing test application and finalize the code, so to start,
we have some HTML, we've got a number of different elements.
We've got an array with all of the words.
And now this is fully dynamic's.
So we can create a new one as well and have that automatically work into our application.
So in sometimes you might get the new one and sometimes you might get one of the older ones.
So this is all random and is fully dynamic.
So if you update and add additional strings into this array, your applications automatically can update
dynamically.
We grabbed all of the elements using our JavaScript.
So document query selector, we added an event listener to the button.
So depending on what it says on the button, we've got different functions that get invoked and we've
got one to start the game and one to end the gameplay.
So for the end gameplay, we need it to still add in one thing here where we're checking to see if the
contents of the string.
So this is where we can add in a condition and we can check to see the string.
So the string is the value of the content that the player typed.
And we can check to see if it's equivalent to the content of the message.
So whatever the message in our text is currently is going to be what the output of the original selection
from the wording was.
And you can see that here within the play game where we were selecting from that array randomly and
then updating that inner text so that value is still going to be present there.
And that's what we can grab that before we before we conclude and we can check to see if they're equal
and if they're not equal, then I'm going to update this.
There were some errors.
So the objective really is within this game is to type everything properly, accurately, as quickly
as possible.
And this should actually be non equal.
So if the string is not equal to the entire text that we're going to see that we've made some errors.
Let's try the suit hit start test and we see that we typed 30 words per minute.
There were some errors in the wording.
We can start it again.
So this time let's type it properly.
So both of those strings should equal.
And let's have done you typed forty four words per minute and we didn't get any error messages because
we typed the string exactly as it was output and to finalize so we can actually get rid of this in our
text, this console message here we had our end play function and then we've got a word count over here.
What we're doing is whatever value string value is brought in here, we're using the JavaScript split
method in order to split it by a space, turning it into an array.
And then every array has a length.
So we're simply returning back that array with a length, with response.
And that gives us a quick way to get the number of words in any string.
And it's in play game.
We're using math random to select a random value from the array, and then we're outputting that random
value into the message in our text area where selecting the date, we're getting the current time and
we're updating the button to done.
So go ahead and try this application out for yourself.
Have some fun with it and update and get familiar with the code.
Thanks again for taking this lesson.