1
00:00:00,180 --> 00:00:05,310
This lesson, we're going to add randomness into the elements as they're being generated and we can

2
00:00:05,310 --> 00:00:07,230
add this into our maker function.

3
00:00:08,510 --> 00:00:13,760
As this is the best place as we're building out these elements, we're generating them, we can also

4
00:00:13,760 --> 00:00:17,120
set the default values that the user has to guests.

5
00:00:17,210 --> 00:00:18,220
And these are going to be hidden.

6
00:00:18,260 --> 00:00:22,670
The backgrounds is going to be no way that the user is going to be able to tell what the values are

7
00:00:22,700 --> 00:00:23,600
that we're looking for.

8
00:00:23,780 --> 00:00:29,960
So let's add in one more object into our element, and this one can be correct.

9
00:00:30,110 --> 00:00:36,620
So whatever the correct value is, and we don't need a function for this, we can use our math random.

10
00:00:38,180 --> 00:00:44,930
Method in JavaScript, Somnath, random, and this is going to produce a random value for that particular

11
00:00:44,930 --> 00:00:51,680
element, and then once we click the check combo, we can loop through all of the elements with a class

12
00:00:51,680 --> 00:00:59,440
of NUM and check those to see if they match whatever the random value is that's being output here.

13
00:00:59,810 --> 00:01:01,220
So let's try that out.

14
00:01:01,460 --> 00:01:03,110
And first, mothe random.

15
00:01:03,110 --> 00:01:11,420
We need to apply math flaw to get rid of the zeros and we also need to multiply math random by a number.

16
00:01:11,430 --> 00:01:12,930
We're going to multiply it by ten.

17
00:01:13,160 --> 00:01:17,990
So this will give us a random number anywhere from zero to nine.

18
00:01:17,990 --> 00:01:21,920
And that's exactly what we want positioned here within our values.

19
00:01:22,130 --> 00:01:28,880
And we can also for now use this same generator where instead of we're setting a value of zero, let's

20
00:01:28,880 --> 00:01:34,520
set that correct value so that we can see it and we can see that is getting generated out.

21
00:01:34,760 --> 00:01:38,270
So now when we click start, we get a random combination.

22
00:01:38,390 --> 00:01:42,210
And this is actually the combination that we're going to have the user guessing.

23
00:01:42,500 --> 00:01:49,760
So the next step is that we're going to set up the check convo button when the player clicks this button

24
00:01:49,760 --> 00:01:50,080
instead.

25
00:01:50,100 --> 00:01:51,350
Just typing checker.

26
00:01:51,530 --> 00:01:55,190
We need to check to see where you need to loop through all of these elements.

27
00:01:55,370 --> 00:01:58,450
And we see that all of them have a class of num.

28
00:01:58,580 --> 00:02:04,910
So we're going to use query selector all select all of the elements with the class of NUM and loop through

29
00:02:04,910 --> 00:02:05,090
them.

30
00:02:05,090 --> 00:02:08,930
And as we iterate through them, we're going to check to see if the numbers are right.

31
00:02:08,930 --> 00:02:14,660
And if they're not, then we're going to send out a message to the user so either that it's low or high

32
00:02:14,660 --> 00:02:16,550
and we can do that with the background color.

33
00:02:16,550 --> 00:02:23,900
So indicating that blue needs to be blue is too low and red is too high and then green is going to be

34
00:02:23,900 --> 00:02:25,690
the background for the correct numbers.

35
00:02:25,850 --> 00:02:27,890
So all of that is coming up in the next lesson.

36
00:02:28,050 --> 00:02:30,650
This lesson, add in the math random.

37
00:02:30,830 --> 00:02:36,740
And afterwards we're going to update the correct value and we're going to update the value back to zero.

38
00:02:36,740 --> 00:02:38,690
So that's still to come in the upcoming lessons.

39
00:02:38,840 --> 00:02:40,270
So go ahead and try this out for yourself.
