1
00:00:00,950 --> 00:00:08,120
This lesson, we're going to complete our typing test application and finalize the code, so to start,

2
00:00:08,120 --> 00:00:11,510
we have some HTML, we've got a number of different elements.

3
00:00:11,780 --> 00:00:14,030
We've got an array with all of the words.

4
00:00:14,150 --> 00:00:15,980
And now this is fully dynamic's.

5
00:00:15,980 --> 00:00:22,310
So we can create a new one as well and have that automatically work into our application.

6
00:00:22,580 --> 00:00:27,350
So in sometimes you might get the new one and sometimes you might get one of the older ones.

7
00:00:27,560 --> 00:00:30,230
So this is all random and is fully dynamic.

8
00:00:30,420 --> 00:00:36,470
So if you update and add additional strings into this array, your applications automatically can update

9
00:00:36,470 --> 00:00:37,120
dynamically.

10
00:00:37,340 --> 00:00:41,090
We grabbed all of the elements using our JavaScript.

11
00:00:41,180 --> 00:00:44,830
So document query selector, we added an event listener to the button.

12
00:00:45,230 --> 00:00:51,260
So depending on what it says on the button, we've got different functions that get invoked and we've

13
00:00:51,260 --> 00:00:54,210
got one to start the game and one to end the gameplay.

14
00:00:54,560 --> 00:01:01,820
So for the end gameplay, we need it to still add in one thing here where we're checking to see if the

15
00:01:01,820 --> 00:01:03,300
contents of the string.

16
00:01:03,600 --> 00:01:07,940
So this is where we can add in a condition and we can check to see the string.

17
00:01:08,210 --> 00:01:13,190
So the string is the value of the content that the player typed.

18
00:01:14,000 --> 00:01:20,920
And we can check to see if it's equivalent to the content of the message.

19
00:01:21,380 --> 00:01:33,260
So whatever the message in our text is currently is going to be what the output of the original selection

20
00:01:33,260 --> 00:01:34,400
from the wording was.

21
00:01:34,610 --> 00:01:41,180
And you can see that here within the play game where we were selecting from that array randomly and

22
00:01:41,180 --> 00:01:45,200
then updating that inner text so that value is still going to be present there.

23
00:01:45,320 --> 00:01:53,030
And that's what we can grab that before we before we conclude and we can check to see if they're equal

24
00:01:53,480 --> 00:01:56,300
and if they're not equal, then I'm going to update this.

25
00:01:56,570 --> 00:01:57,700
There were some errors.

26
00:01:58,160 --> 00:02:04,610
So the objective really is within this game is to type everything properly, accurately, as quickly

27
00:02:04,610 --> 00:02:05,600
as possible.

28
00:02:05,960 --> 00:02:09,010
And this should actually be non equal.

29
00:02:09,020 --> 00:02:14,000
So if the string is not equal to the entire text that we're going to see that we've made some errors.

30
00:02:14,180 --> 00:02:19,620
Let's try the suit hit start test and we see that we typed 30 words per minute.

31
00:02:19,910 --> 00:02:21,950
There were some errors in the wording.

32
00:02:22,490 --> 00:02:23,690
We can start it again.

33
00:02:23,840 --> 00:02:25,820
So this time let's type it properly.

34
00:02:26,000 --> 00:02:28,910
So both of those strings should equal.

35
00:02:28,910 --> 00:02:34,670
And let's have done you typed forty four words per minute and we didn't get any error messages because

36
00:02:34,670 --> 00:02:41,000
we typed the string exactly as it was output and to finalize so we can actually get rid of this in our

37
00:02:41,000 --> 00:02:49,130
text, this console message here we had our end play function and then we've got a word count over here.

38
00:02:49,130 --> 00:02:56,210
What we're doing is whatever value string value is brought in here, we're using the JavaScript split

39
00:02:56,330 --> 00:03:01,520
method in order to split it by a space, turning it into an array.

40
00:03:01,730 --> 00:03:03,740
And then every array has a length.

41
00:03:03,950 --> 00:03:08,270
So we're simply returning back that array with a length, with response.

42
00:03:08,360 --> 00:03:12,350
And that gives us a quick way to get the number of words in any string.

43
00:03:12,710 --> 00:03:14,330
And it's in play game.

44
00:03:14,360 --> 00:03:23,000
We're using math random to select a random value from the array, and then we're outputting that random

45
00:03:23,000 --> 00:03:29,690
value into the message in our text area where selecting the date, we're getting the current time and

46
00:03:29,690 --> 00:03:31,850
we're updating the button to done.

47
00:03:32,330 --> 00:03:35,210
So go ahead and try this application out for yourself.

48
00:03:36,510 --> 00:03:40,540
Have some fun with it and update and get familiar with the code.

49
00:03:41,100 --> 00:03:42,660
Thanks again for taking this lesson.
