1
00:00:00,120 --> 00:00:06,960
Are you ready to apply some game logic visually, we have most of what we need and most of the functionality,

2
00:00:07,230 --> 00:00:09,380
but we don't have a working game.

3
00:00:09,390 --> 00:00:13,690
We have the word, we have it being displayed visually to the player.

4
00:00:14,070 --> 00:00:20,790
We also have clickable letters and they only can be clicked once because we're removing the event listener

5
00:00:20,790 --> 00:00:27,540
after they get clicked and because we've already appended them to output, too, we can select them

6
00:00:27,540 --> 00:00:32,640
and using documents, query selector and we're doing a query selector all.

7
00:00:32,850 --> 00:00:36,900
We're going to select all the elements with a class of letter two.

8
00:00:37,290 --> 00:00:42,630
So these are all the ones that we created earlier as we were looping through the player solution.

9
00:00:42,810 --> 00:00:48,870
We created a bunch of divs there, appending them because we need to have ability to loop through all

10
00:00:48,870 --> 00:00:54,180
of these letters to check, to see if the letter that got clicked is going to match any of the letters

11
00:00:54,180 --> 00:00:55,380
that we have in our output.

12
00:00:55,500 --> 00:00:57,570
And if it is, then we want to write that in.

13
00:00:57,780 --> 00:00:59,790
So that's what we need to loop through those values.

14
00:01:00,030 --> 00:01:06,330
And we can do that within that handler function that we created is taking our solution letter, looping

15
00:01:06,330 --> 00:01:09,150
through, using for each selecting the function.

16
00:01:09,330 --> 00:01:13,710
And this could also be letter one letter and enter.

17
00:01:14,690 --> 00:01:24,320
HTML is not equal to the underscore, and if it's not equal to it, that means that there's a letter

18
00:01:24,320 --> 00:01:30,560
that calculate out the solution, add up a variable, and this is going to count how many letters the

19
00:01:30,560 --> 00:01:31,160
player has.

20
00:01:31,160 --> 00:01:31,470
Right.

21
00:01:31,670 --> 00:01:37,880
So as we loop through and we need to write in the letters here, so it's not going to be just an underscore.

22
00:01:37,880 --> 00:01:39,860
We need to write in a letter actually in there.

23
00:01:39,920 --> 00:01:48,100
So let's do our check to see if the letter that the player selected and we have that value in temp already.

24
00:01:48,560 --> 00:01:53,370
So checking to see if letter and my letter value.

25
00:01:53,420 --> 00:02:01,460
So remember over here when we were building out that letter to we were hiding within the object of value

26
00:02:01,460 --> 00:02:05,030
of my letter, which equaled the letter of the output.

27
00:02:05,660 --> 00:02:12,500
So we can use that now and check that and we need to turn it to uppercase so that they're all matching

28
00:02:12,500 --> 00:02:13,650
uppercase values.

29
00:02:13,650 --> 00:02:16,940
So it's a JavaScript function to to uppercase that.

30
00:02:17,210 --> 00:02:19,520
And we're going to check to see if it's equal to temp.

31
00:02:20,210 --> 00:02:24,010
And if it is, then we know that the player got something right.

32
00:02:24,320 --> 00:02:32,100
So we need to update the inner HTML of that layer object or it could be in our text as well to temp.

33
00:02:32,750 --> 00:02:33,860
So let's see what happens now.

34
00:02:33,890 --> 00:02:36,500
So Head Start and we know what our word is.

35
00:02:36,500 --> 00:02:42,980
JavaScript, when I hit a we see both of the A's fill out G v.

36
00:02:43,700 --> 00:02:46,460
S, and I think I know what the solution is.

37
00:02:47,150 --> 00:02:53,180
JavaScript, of course, very timely to be placed within our course.

38
00:02:53,330 --> 00:02:56,630
So JavaScript, so we got everything right.

39
00:02:56,630 --> 00:02:59,590
And we do have a count of how many letters are correct.

40
00:02:59,900 --> 00:03:06,860
So that leads to the next part where we can provide some type of output for the player that's interacting

41
00:03:06,860 --> 00:03:07,610
with the content.

42
00:03:07,790 --> 00:03:10,600
So that's the next piece of logic that we need to add in.

43
00:03:10,730 --> 00:03:16,010
We need to be able to check to see if the player's solved it, as well as more messaging to the player

44
00:03:16,130 --> 00:03:18,910
so they know what is happening during the gameplay.

45
00:03:19,310 --> 00:03:20,940
So that's still to come in the upcoming lesson.

46
00:03:21,290 --> 00:03:26,240
So now go ahead and add in the logic to check to see if the player selected the right letters.
