Nice job and what we've got next question, functionality out of the way now would want to set up the
functionality for correct question.
So when I click on the answer buttons, I would want to check whether the answer is correct and then
regardless whether the answer is correct or not, I would want to move on to the next question.
And again, the functionality is following where if I click on the answer, at least I have a chance
of getting something right.
If I go to the next question, I just skip it and there's no way for me to get that correct answer.
And we're going to set up another function here.
And of course, the name will be check and then answer.
And here I'll pass in the value.
So you'll see in a second what we're passing in in the objets.
But this is just going to be a value and there's going to be two questions.
Either value is true or it is false.
Now, if the value will be true, so say here, if the value is true, then I would want to go set.
Correct, since, of course, I would want to increase that state value of correct.
And the function that does that.
Is that correct?
And again, we're going to go with functional approach where we go with old and I'll call this old state
or current state and of course plus one.
So if the answer is correct, we simply add one to our state value.
So return all state plus one.
Now, like I said, regardless, I'm going to go with my next question.
So if this is not true, then we simply don't have that correct.
But either way, we go to the next question.
Now, of course, I do need to pass in that Czech answer.
So right after next question, we go check, answer, and then instead of the app, yes, we would need
to navigate to those.
So let's head on over there and I'm going to keep on scrolling.
Keep on scrolling.
There is my button.
So above or after dangerously set in the amount that is really up to you.
I'm going to go on click.
And by the way, I skipped one step where, of course, I would need the structure as well.
Correct.
So we're going to go here with a check and answer.
That's my function name and it's coming from my global context.
And then here I have unclick.
And once I click what I would want to do, well, I would want to run the arrow function since I only
want to do that when I click on the button.
So I only want to run my check answer when I click on my button.
And then what I'm going to pass into the Czech answer because remember, in the context, yes, we are
looking for some kind of value.
Now, the way I'll check whether the answer is correct, I'll simply pass in as an argument to things
I'll say if the correct answer and the correct answer, of course, is coming from my question.
Right.
Remember when we did the structured question, incorrect answers and correct answers, all that was
coming from my current question.
So this is going to be the correct answer, which in this case is going to be twenty two, because I
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
answer because I'm iterating over my answers and answers are stored as string and in the correct answer
I just pass in is the correct answer equal to my current answer.
So the answer that I'm displaying here in the bottom, if it is, then of course I pass it.
Now, if it is false, then the value here will be false.
So again, let me go over the functionality.
I check here for the value now in the objets, that value is just true or false.
So I have my answers armatrading over and for every answer I'm displaying the button.
And then once I click on a button, I check whether the answer that is set in the button is equal to
the correct answer.
If it is, then in the state I set correct plus one.
If not, I don't do anything regardless whether the answer is correct or not.
We move on to the next question.
So now, of course, I'm going to be cheating a little bit because I know that the last answer always
going to be the right one.
So I have one correct answer and I have answered one question that I'm going to do the same thing here
and notice how every time I'm clicking because I'm getting the correct plus one.
And I also show the current index, which essentially just tells me that I have four questions answered
correctly and then I'm going to show just round one.
Now, of course, I have only four because this wasn't the correct answer.
And now it tells me that I answered six questions and I'm going to keep on going now.
I'm going to answer some correctly as well.
And eventually, of course, I'll come to zero because we still haven't set up the model functionality.