When your users make a choice in your app, they need visual feedback. In this video, add code to your project to show the user if their answer was correct or incorrect.
- [Instructor] So now that we've got the majority … of our functionality down, … it's finally time to put back our icons at the bottom … to be able to track the user's score. … So, the part where we're actually figuring out if the user … got the question right or wrong is right here. … And you can see that at the moment, … it's repeated in two places, right? … When the user picks false, … and also when the user picks true. … So let's consolidate all of that code together … into a single function. … So we'll do it right up here, … just below where we have our scoreKeeper. … And we're going to call that method, … because we're inside a class, so this is going to be a method … that's associated with the class, … and this method is going to be called checkAnswer. … And checkAnswer is going to take a single input … and the parameter is going to be a boolean type … that's going to be called userPikedAnswer. … And then inside the parasynthesis, … we're going to actually go about checking the answer, …
This course was created by London App Brewery. We are pleased to host this content in our library.