1
00:00:00,810 --> 00:00:05,700
This lesson, we're going to be wrapping up our application and we need a way for the player to be able

2
00:00:05,700 --> 00:00:08,460
to make a guess of the scrambled word.

3
00:00:08,490 --> 00:00:10,350
So let's go through our application quickly.

4
00:00:10,600 --> 00:00:16,470
We start we're presented with a scrambled word, and now it's up to the player to guess what that word

5
00:00:16,470 --> 00:00:16,830
is.

6
00:00:16,980 --> 00:00:22,230
And once the player types in the word, we want them to be able to hit guess and have that checked to

7
00:00:22,230 --> 00:00:25,380
see if the word is the actual one that we've selected.

8
00:00:25,620 --> 00:00:27,010
And that's where we've got the else.

9
00:00:27,240 --> 00:00:33,900
So if the inplay is already started that we don't need to generate any more words and we're going to

10
00:00:33,900 --> 00:00:39,210
let the player guess whatever the word is, remember, we've got this store globally, whatever the

11
00:00:39,210 --> 00:00:44,330
word value is that we want it to output and we just need to check to see if it matches.

12
00:00:44,640 --> 00:00:49,260
So selecting our elements, we'll take our temp guess value.

13
00:00:49,380 --> 00:00:54,720
And this is the value that's contained within the input we've already got the input under the query

14
00:00:54,720 --> 00:00:55,230
selector.

15
00:00:55,230 --> 00:01:03,480
Guess so we can take that object guess and select the value of guess and all console logged out for

16
00:01:03,480 --> 00:01:03,720
now.

17
00:01:03,720 --> 00:01:08,930
So tenth guess so that we can see and make sure that we're actually picking up that value.

18
00:01:09,150 --> 00:01:11,910
So type and test we see that we've got test there.

19
00:01:12,030 --> 00:01:18,510
So now it's just a matter of typing in a condition to check to see the temp guess is equal to and we

20
00:01:18,510 --> 00:01:21,510
can use an absolute equal to such a three equal signs there.

21
00:01:21,690 --> 00:01:25,350
And that also checks the type because both of them are going to be strings.

22
00:01:25,890 --> 00:01:28,890
So we're checking to see if they're actually equivalent.

23
00:01:29,160 --> 00:01:32,340
And if they are, then we're going to type in the console.

24
00:01:32,790 --> 00:01:33,390
Correct.

25
00:01:33,510 --> 00:01:38,760
And if they're not, then we've got an else statement and they need to guess again and we'll say yes

26
00:01:38,790 --> 00:01:39,270
again.

27
00:01:39,300 --> 00:01:40,230
So let's try that out.

28
00:01:40,680 --> 00:01:46,650
So now we start and we don't we're going to hide this eventually so we don't know what the word is.

29
00:01:46,650 --> 00:01:50,580
But during testing, I usually like to have that value there.

30
00:01:50,730 --> 00:01:54,030
And we can see that we've got guess again, we've got correct.

31
00:01:54,150 --> 00:01:58,770
So when we do get the correct answer, we see that we are returning back.

32
00:01:58,770 --> 00:01:59,250
Correct.

33
00:01:59,700 --> 00:02:04,350
So that should lead us to actually to have another option.

34
00:02:04,500 --> 00:02:07,740
And that's going to be to start the inplay once again.

35
00:02:07,840 --> 00:02:09,210
So let's update that.

36
00:02:09,210 --> 00:02:15,660
And if we did get it correct, we can update that and we can also update the message to the player so

37
00:02:15,660 --> 00:02:18,210
the inner HTML can be correct.

38
00:02:18,210 --> 00:02:19,410
It was.

39
00:02:19,410 --> 00:02:24,700
And also we'll output that scrambled word there and we'll also let the player start again.

40
00:02:24,900 --> 00:02:28,530
So what we did over here, we're just going to do the opposite.

41
00:02:28,650 --> 00:02:31,740
So start and we're going to simply toggle this value.

42
00:02:31,920 --> 00:02:33,060
Let's try that again.

43
00:02:33,060 --> 00:02:39,150
And this time, if we get it right and I was so hoping to get to Mellissa document, I just got to copy

44
00:02:39,150 --> 00:02:40,950
and paste that and guess so.

45
00:02:40,950 --> 00:02:41,370
Correct.

46
00:02:41,370 --> 00:02:42,360
It was document.

47
00:02:42,540 --> 00:02:43,650
We can start it again.

48
00:02:43,800 --> 00:02:48,810
So there's another word and guess that again, I'm going to add in a little bit of styling so that we

49
00:02:48,810 --> 00:02:54,840
can have some spacing between these words and we can also output that font size to be quite a bit larger.

50
00:02:54,840 --> 00:03:01,200
So where it's actually font size and I'm going to make it to m also adding in a margin at the bottom.

51
00:03:01,200 --> 00:03:02,460
So we've got some spacing.

52
00:03:02,460 --> 00:03:05,730
Try that out as our guests and let's do website.

53
00:03:05,730 --> 00:03:09,210
So guess it and correct it was website start again.

54
00:03:09,210 --> 00:03:16,140
You can also score the number of tries and turns that it takes so you can have that as a global variable

55
00:03:16,620 --> 00:03:18,870
and started out to equal zero.

56
00:03:19,290 --> 00:03:24,060
And then every time we start the game we're going to restart that value to zero.

57
00:03:24,060 --> 00:03:31,800
And then every time we take a guess, we can increment score and then add to the statement guesses.

58
00:03:31,830 --> 00:03:33,290
Let's try that one more time.

59
00:03:33,450 --> 00:03:38,160
So now we know its website, but let's say let's do a few temporary guesses.

60
00:03:38,820 --> 00:03:40,560
So website and correct.

61
00:03:40,560 --> 00:03:41,310
It was website.

62
00:03:41,310 --> 00:03:43,770
It took two guesses at in a space there.

63
00:03:43,800 --> 00:03:49,800
So that's essentially our quick game in order for a guessing game and again, once again, fully dynamic.

64
00:03:49,980 --> 00:03:56,280
So even if you add in new content here, so let's add in the word new, it's going to be dynamic and

65
00:03:56,280 --> 00:03:57,810
it's not going to fail.

66
00:03:57,810 --> 00:04:03,270
We see that we get all of those elements generated out and eventually we're also going to get new as

67
00:04:03,270 --> 00:04:03,600
well.

68
00:04:03,630 --> 00:04:07,080
And so we see that we also get that new value that we just added in.
