1
00:00:00,180 --> 00:00:04,590
Let's do a quick overview of the content and the game that we built out.

2
00:00:04,950 --> 00:00:07,010
We had a little bit of styling that we added in.

3
00:00:07,350 --> 00:00:13,110
We also added in some HTML so that the user has a play area and some content to interact with.

4
00:00:13,560 --> 00:00:19,920
Then we selected the elements from the page that we needed to utilize as JavaScript objects so that

5
00:00:19,920 --> 00:00:23,190
we can quickly access them, manipulate them and make updates to them.

6
00:00:23,460 --> 00:00:27,810
And that's connecting it to the DOM object using document selector.

7
00:00:28,170 --> 00:00:32,640
We had some variables that we needed to set up for the gameplay added in an event.

8
00:00:32,640 --> 00:00:35,260
Lyster to the button and then this button.

9
00:00:35,400 --> 00:00:41,040
So the first time it runs through this is basically our start sequence that we run through on the first

10
00:00:41,040 --> 00:00:41,370
time.

11
00:00:41,580 --> 00:00:43,620
So we're updating the interest to the button.

12
00:00:43,620 --> 00:00:45,360
So changes to guess from start.

13
00:00:45,630 --> 00:00:48,600
We were hiding and hiding the input field.

14
00:00:48,930 --> 00:00:52,830
We were creating a word using our function to create a word.

15
00:00:52,980 --> 00:00:58,620
And what all this was doing, this was just generating a random index value and then getting that random

16
00:00:58,620 --> 00:01:03,930
index value, selecting an item from the array, using the index value and then returning that word

17
00:01:03,960 --> 00:01:05,300
that we've just generated out.

18
00:01:06,060 --> 00:01:11,310
We also so we generate the word randomly from the array and then we scramble that word.

19
00:01:11,310 --> 00:01:17,220
And this was the interesting part of this section is that we created a way to randomize content in an

20
00:01:17,220 --> 00:01:17,540
array.

21
00:01:17,700 --> 00:01:19,430
And again, this is a very useful function.

22
00:01:19,680 --> 00:01:22,170
So we loop through the array and we swapped.

23
00:01:22,470 --> 00:01:28,050
So we moved through the array, the of length of that array, and we swapped items within the array.

24
00:01:28,080 --> 00:01:29,130
So index values.

25
00:01:29,280 --> 00:01:32,760
So we created a temp, one random index value.

26
00:01:32,880 --> 00:01:35,460
And then what we did over here is this is just a swap.

27
00:01:35,580 --> 00:01:42,180
And as you can see, we're taking I setting it to J and then taking J and setting it to AI and then

28
00:01:42,180 --> 00:01:43,890
we're returning to a rate that we just created.

29
00:01:44,430 --> 00:01:47,700
And that is all happening here within the random array.

30
00:01:47,790 --> 00:01:50,820
And then once we return it back, it's still with an array format.

31
00:01:50,970 --> 00:01:54,020
So we need to join it together to turn it back into a string.

32
00:01:54,030 --> 00:01:57,090
Once we turn it into a string, we can output that scrambled word.

33
00:01:57,330 --> 00:01:58,620
We'll get rid of the solution.

34
00:01:58,740 --> 00:02:04,490
And then if we're allowing the player to make guesses, this is the guess value.

35
00:02:04,500 --> 00:02:06,780
So it's just taking that value from the input field.

36
00:02:07,080 --> 00:02:08,400
We're updating the score.

37
00:02:08,700 --> 00:02:14,280
We can get rid of the console message and we're equaling or checking to see if the player got a correct

38
00:02:14,280 --> 00:02:14,700
answer.

39
00:02:14,700 --> 00:02:17,730
And if they did, then this is what we do for correct.

40
00:02:17,860 --> 00:02:20,160
Essentially, we output the message of correct.

41
00:02:20,370 --> 00:02:28,920
We set reset our new word generation function so that next time we click the button, it will be start

42
00:02:29,070 --> 00:02:31,700
and we're going to go through the setup again.

43
00:02:32,070 --> 00:02:38,670
So using the inplay as a boolean value, we update the value of the button once again to B start.

44
00:02:39,150 --> 00:02:44,760
We output a message to the user so they know what happened and then we toggle that input field, so

45
00:02:44,760 --> 00:02:47,010
we hide it so it's no longer available.

46
00:02:47,670 --> 00:02:54,300
And if we got it wrong, then simply right now in the console, like we're putting guess again and here

47
00:02:54,300 --> 00:03:00,570
we can actually output and we could say wrong and we still need to output the word again.

48
00:03:00,570 --> 00:03:04,050
So we need to output whatever that scrambled word is.

49
00:03:04,530 --> 00:03:09,780
So start and if I get it wrong, I get wrong and I still have the same word.

50
00:03:10,050 --> 00:03:15,070
Or if you wanted to, you could randomize the order of the word if you wanted to.

51
00:03:15,240 --> 00:03:19,050
So every time they get it wrong, we can switch the letters around.

52
00:03:19,260 --> 00:03:21,990
So eventually that can be a little bit more interesting for the player.

53
00:03:22,170 --> 00:03:25,740
So there's quite a few things that you can do to extend on this application.

54
00:03:26,280 --> 00:03:33,570
Thanks again for taking this section and learning more about how you can apply randomness to arrays

55
00:03:33,750 --> 00:03:36,360
and put it into a working application game.
