1 00:00:00,360 --> 00:00:01,230 Excellent work. 2 00:00:01,260 --> 00:00:08,310 We're almost done now, of course, we just want to make it a bit harder for a user where the correct 3 00:00:08,310 --> 00:00:12,730 answer is not going to be always at the end of our. 4 00:00:13,110 --> 00:00:14,820 So I'll leave this for your reference. 5 00:00:14,850 --> 00:00:20,030 That's why I'll come to the south and we'll create a new jury in this case. 6 00:00:20,040 --> 00:00:24,740 I'm going to go with that and we'll say answers is equal to that. 7 00:00:24,750 --> 00:00:25,230 Not so. 8 00:00:25,230 --> 00:00:28,020 I'll spread out the incorrect answers. 9 00:00:28,380 --> 00:00:35,070 And of course, what happens right now, I have the right by the name of answers, and there I have 10 00:00:35,070 --> 00:00:38,060 the values coming from the incorrect answers. 11 00:00:38,340 --> 00:00:45,510 And then once I have my answers, the way I would want to generate a random number every time I display 12 00:00:45,540 --> 00:00:46,220 a question. 13 00:00:46,500 --> 00:00:52,110 So we know that, of course, our questions are changing because our index is changing and that every 14 00:00:52,110 --> 00:00:56,540 time we get a new question, I would want to generate that random number. 15 00:00:56,850 --> 00:01:04,560 Now, I can also tell you that it might get a bit annoying where we'll have to get a new set of questions 16 00:01:04,560 --> 00:01:07,150 every time we say something in the abstract. 17 00:01:07,500 --> 00:01:13,250 So once I make some changes and if I want to see counsel, I will have to generate a new set of questions. 18 00:01:13,530 --> 00:01:20,130 So that might get a bit annoying, but I think it is going to be easier for all of us to be on the same 19 00:01:20,130 --> 00:01:22,820 page if I can log my values. 20 00:01:23,160 --> 00:01:25,680 So let's create that random number. 21 00:01:25,680 --> 00:01:28,770 So tempting index and that is going to be equal to the math. 22 00:01:28,770 --> 00:01:36,900 Random now, math, random returns a random number between zero and zero point and ninety nine, not 23 00:01:36,900 --> 00:01:37,770 including one. 24 00:01:38,280 --> 00:01:45,780 But the thing is, I would want to generate a random number between zero and three y one because I know 25 00:01:45,780 --> 00:01:54,060 that my answers already eventually is going to have four values and first index is going to be zero 26 00:01:54,210 --> 00:01:55,690 and the last one will be three. 27 00:01:56,040 --> 00:02:02,820 Now, in order to get that, I first only to invoke my random and then I need to multiply this by four. 28 00:02:02,820 --> 00:02:08,040 But the thing is, I don't want three point six or whatever decimal value. 29 00:02:08,280 --> 00:02:10,360 Instead, I always want to round it down. 30 00:02:10,800 --> 00:02:18,420 So on here I will say math and then four and we pass in that math, round them by four. 31 00:02:18,900 --> 00:02:26,520 And once we have this one, let's comes along the temp index and what we should get is the random values 32 00:02:26,940 --> 00:02:30,000 between zero and three. 33 00:02:30,870 --> 00:02:34,880 It's never going to be four, but it might be zero. 34 00:02:35,130 --> 00:02:36,090 So it share it. 35 00:02:36,450 --> 00:02:39,300 I will, I guess, navigate the bigger screen. 36 00:02:39,930 --> 00:02:45,010 We just submit these rulers and then in the council notice now the value is three. 37 00:02:45,420 --> 00:02:50,370 So once I click the next question now, the value for my random one is zero. 38 00:02:50,610 --> 00:02:54,800 Then I have another zero, then I have zero, then I have zero and then I have one. 39 00:02:55,230 --> 00:03:01,530 So even though technically this was random, it just came out that way where I had four zero zero. 40 00:03:01,920 --> 00:03:05,860 But at least you can see that we are getting these random numbers. 41 00:03:06,210 --> 00:03:07,070 So what is next? 42 00:03:07,110 --> 00:03:12,840 Well, next, I would want to set up my logic and this is going to be the case where I'll type everything 43 00:03:12,840 --> 00:03:15,380 up and then I'll go over what is happening. 44 00:03:15,660 --> 00:03:18,750 So I'll check if the temp index is equal to three. 45 00:03:19,170 --> 00:03:25,020 And if that is the case, I'm going to go with answers that push and I'm just going to add that correct 46 00:03:25,020 --> 00:03:25,480 answer. 47 00:03:25,980 --> 00:03:32,910 So if the index value is going to be three, similarly how I had previously, I'm just going to place 48 00:03:32,910 --> 00:03:36,410 the correct answer at the end of my answers. 49 00:03:36,420 --> 00:03:36,790 All right. 50 00:03:37,080 --> 00:03:40,140 So I just go with push, which at the end of. 51 00:03:40,140 --> 00:03:40,550 All right. 52 00:03:40,800 --> 00:03:42,870 And I have the correct answer. 53 00:03:43,110 --> 00:03:46,660 So that is going to be the case if the value is equal to three. 54 00:03:47,130 --> 00:03:54,000 Now, if the value is not equal to three, if the value is equal to zero one or two, then we need to 55 00:03:54,000 --> 00:04:01,650 do a little bit of work where first of all, I will push the current value that I have in the next to 56 00:04:01,650 --> 00:04:02,500 the end of the array. 57 00:04:02,790 --> 00:04:08,660 So that's why I go with answer that push and then I'm looking for that particular value. 58 00:04:08,820 --> 00:04:12,660 So temp index and then move the correct one in that spot. 59 00:04:12,810 --> 00:04:17,180 Again, let me type it out and then I'll go over it in greater detail. 60 00:04:17,460 --> 00:04:25,210 So I look for temp index, whatever it is, and I'll set it equal to my correct answer. 61 00:04:25,500 --> 00:04:26,880 So what is happening over here? 62 00:04:27,240 --> 00:04:35,100 Well, the answer is not defined, so it should be answers, not Bush over here and the way it works. 63 00:04:35,340 --> 00:04:39,780 We have answers here and I just add these incorrect answers. 64 00:04:40,260 --> 00:04:42,210 So, of course, I have an array of three items. 65 00:04:42,210 --> 00:04:42,600 Correct. 66 00:04:42,960 --> 00:04:47,420 And they have indexes of zero, one and two. 67 00:04:47,880 --> 00:04:57,020 Then I generate random number and that random number could be zero one, two or three. 68 00:04:57,600 --> 00:04:59,940 So if the number is three, what does that? 69 00:05:00,800 --> 00:05:06,680 Well, that means that technically there is no such index in disarray, correct, because this one will 70 00:05:06,680 --> 00:05:10,190 always be three, it will always be three items. 71 00:05:10,220 --> 00:05:12,100 So the last index will be true. 72 00:05:12,500 --> 00:05:21,350 So if my random number is three, then the only thing I do is just add my correct answer at the end 73 00:05:21,350 --> 00:05:22,170 of the day. 74 00:05:22,850 --> 00:05:24,560 Similarly, like we had before. 75 00:05:24,560 --> 00:05:27,500 But keep in mind that this is generated randomly. 76 00:05:27,680 --> 00:05:31,310 In this case, we were always placing that correct answer at the end. 77 00:05:31,790 --> 00:05:32,600 Not in here. 78 00:05:32,720 --> 00:05:36,560 In here, only if the temp index is equal to three. 79 00:05:36,920 --> 00:05:38,540 OK, hopefully that is clear. 80 00:05:38,840 --> 00:05:49,070 And then if the random number is either zero, one or two, I take the index, whatever it is from my 81 00:05:49,070 --> 00:05:51,620 error and add it to the end of. 82 00:05:51,620 --> 00:05:51,920 All right. 83 00:05:52,280 --> 00:05:54,680 So imagine my temp index is two. 84 00:05:55,370 --> 00:06:01,550 I push to the end of array, the item that has the index of two hours ago. 85 00:06:01,550 --> 00:06:02,690 It answers that portion. 86 00:06:02,870 --> 00:06:06,100 And then I'm looking for that item that has the index off to. 87 00:06:06,620 --> 00:06:08,420 So add it to the end of right. 88 00:06:08,570 --> 00:06:12,670 And then in that spot I place the correct answer. 89 00:06:13,220 --> 00:06:14,420 So hopefully that is clear. 90 00:06:14,630 --> 00:06:17,510 If you need to do some login, please do so. 91 00:06:17,780 --> 00:06:19,560 But in my case I will test it out. 92 00:06:19,730 --> 00:06:23,360 So let me click on start and I'll try to cheat again. 93 00:06:23,780 --> 00:06:31,610 But notice when I click on the last button, I can see that these answers are not correct, which is 94 00:06:31,610 --> 00:06:32,510 really, really good. 95 00:06:32,730 --> 00:06:36,230 That means that of course now we have a random powers. 96 00:06:36,590 --> 00:06:41,720 So actually the user needs to know the right answer. 97 00:06:42,010 --> 00:06:43,110 That is our application. 98 00:06:43,130 --> 00:06:46,430 Hopefully everyone enjoyed it and I hope to see the next one.