1 00:00:00,330 --> 00:00:07,230 Nice job and what we've got next question, functionality out of the way now would want to set up the 2 00:00:07,230 --> 00:00:09,510 functionality for correct question. 3 00:00:10,120 --> 00:00:19,320 So when I click on the answer buttons, I would want to check whether the answer is correct and then 4 00:00:19,320 --> 00:00:24,650 regardless whether the answer is correct or not, I would want to move on to the next question. 5 00:00:25,140 --> 00:00:31,410 And again, the functionality is following where if I click on the answer, at least I have a chance 6 00:00:31,410 --> 00:00:32,450 of getting something right. 7 00:00:32,880 --> 00:00:39,470 If I go to the next question, I just skip it and there's no way for me to get that correct answer. 8 00:00:39,930 --> 00:00:42,120 And we're going to set up another function here. 9 00:00:42,720 --> 00:00:46,070 And of course, the name will be check and then answer. 10 00:00:46,570 --> 00:00:48,530 And here I'll pass in the value. 11 00:00:49,050 --> 00:00:53,430 So you'll see in a second what we're passing in in the objets. 12 00:00:53,430 --> 00:00:58,290 But this is just going to be a value and there's going to be two questions. 13 00:00:58,470 --> 00:01:01,570 Either value is true or it is false. 14 00:01:01,920 --> 00:01:08,950 Now, if the value will be true, so say here, if the value is true, then I would want to go set. 15 00:01:09,000 --> 00:01:13,800 Correct, since, of course, I would want to increase that state value of correct. 16 00:01:14,070 --> 00:01:15,420 And the function that does that. 17 00:01:15,420 --> 00:01:16,260 Is that correct? 18 00:01:17,190 --> 00:01:23,280 And again, we're going to go with functional approach where we go with old and I'll call this old state 19 00:01:23,280 --> 00:01:25,800 or current state and of course plus one. 20 00:01:26,280 --> 00:01:32,120 So if the answer is correct, we simply add one to our state value. 21 00:01:32,430 --> 00:01:34,710 So return all state plus one. 22 00:01:35,010 --> 00:01:39,200 Now, like I said, regardless, I'm going to go with my next question. 23 00:01:39,690 --> 00:01:43,990 So if this is not true, then we simply don't have that correct. 24 00:01:44,670 --> 00:01:47,240 But either way, we go to the next question. 25 00:01:47,580 --> 00:01:50,570 Now, of course, I do need to pass in that Czech answer. 26 00:01:51,150 --> 00:01:58,680 So right after next question, we go check, answer, and then instead of the app, yes, we would need 27 00:01:58,680 --> 00:02:00,120 to navigate to those. 28 00:02:00,570 --> 00:02:04,020 So let's head on over there and I'm going to keep on scrolling. 29 00:02:04,020 --> 00:02:04,710 Keep on scrolling. 30 00:02:04,710 --> 00:02:06,240 There is my button. 31 00:02:06,840 --> 00:02:12,210 So above or after dangerously set in the amount that is really up to you. 32 00:02:12,480 --> 00:02:13,800 I'm going to go on click. 33 00:02:13,800 --> 00:02:18,750 And by the way, I skipped one step where, of course, I would need the structure as well. 34 00:02:18,750 --> 00:02:19,160 Correct. 35 00:02:19,500 --> 00:02:22,590 So we're going to go here with a check and answer. 36 00:02:22,950 --> 00:02:25,890 That's my function name and it's coming from my global context. 37 00:02:26,400 --> 00:02:29,070 And then here I have unclick. 38 00:02:30,040 --> 00:02:35,620 And once I click what I would want to do, well, I would want to run the arrow function since I only 39 00:02:35,620 --> 00:02:38,830 want to do that when I click on the button. 40 00:02:39,100 --> 00:02:43,500 So I only want to run my check answer when I click on my button. 41 00:02:43,870 --> 00:02:50,590 And then what I'm going to pass into the Czech answer because remember, in the context, yes, we are 42 00:02:50,590 --> 00:02:52,570 looking for some kind of value. 43 00:02:53,200 --> 00:03:00,820 Now, the way I'll check whether the answer is correct, I'll simply pass in as an argument to things 44 00:03:01,150 --> 00:03:06,940 I'll say if the correct answer and the correct answer, of course, is coming from my question. 45 00:03:07,540 --> 00:03:07,900 Right. 46 00:03:08,530 --> 00:03:15,820 Remember when we did the structured question, incorrect answers and correct answers, all that was 47 00:03:15,820 --> 00:03:17,960 coming from my current question. 48 00:03:18,460 --> 00:03:22,570 So this is going to be the correct answer, which in this case is going to be twenty two, because I 49 00:03:22,570 --> 00:03:31,090 know that I set this up as a last item in my area and I'm going to check whether it is equal to my current 50 00:03:31,090 --> 00:03:39,070 answer because I'm iterating over my answers and answers are stored as string and in the correct answer 51 00:03:39,430 --> 00:03:45,440 I just pass in is the correct answer equal to my current answer. 52 00:03:45,910 --> 00:03:51,340 So the answer that I'm displaying here in the bottom, if it is, then of course I pass it. 53 00:03:52,360 --> 00:03:56,110 Now, if it is false, then the value here will be false. 54 00:03:56,680 --> 00:03:58,720 So again, let me go over the functionality. 55 00:03:59,200 --> 00:04:05,630 I check here for the value now in the objets, that value is just true or false. 56 00:04:05,950 --> 00:04:11,280 So I have my answers armatrading over and for every answer I'm displaying the button. 57 00:04:11,710 --> 00:04:19,060 And then once I click on a button, I check whether the answer that is set in the button is equal to 58 00:04:19,060 --> 00:04:20,020 the correct answer. 59 00:04:20,320 --> 00:04:25,090 If it is, then in the state I set correct plus one. 60 00:04:25,330 --> 00:04:30,550 If not, I don't do anything regardless whether the answer is correct or not. 61 00:04:30,770 --> 00:04:32,660 We move on to the next question. 62 00:04:33,070 --> 00:04:38,620 So now, of course, I'm going to be cheating a little bit because I know that the last answer always 63 00:04:38,620 --> 00:04:39,630 going to be the right one. 64 00:04:39,940 --> 00:04:46,210 So I have one correct answer and I have answered one question that I'm going to do the same thing here 65 00:04:46,210 --> 00:04:52,180 and notice how every time I'm clicking because I'm getting the correct plus one. 66 00:04:52,510 --> 00:05:00,250 And I also show the current index, which essentially just tells me that I have four questions answered 67 00:05:00,250 --> 00:05:02,970 correctly and then I'm going to show just round one. 68 00:05:03,550 --> 00:05:08,200 Now, of course, I have only four because this wasn't the correct answer. 69 00:05:08,440 --> 00:05:14,050 And now it tells me that I answered six questions and I'm going to keep on going now. 70 00:05:14,050 --> 00:05:16,030 I'm going to answer some correctly as well. 71 00:05:16,270 --> 00:05:23,620 And eventually, of course, I'll come to zero because we still haven't set up the model functionality.