Camera 1
Now to dive into the last challenge for this course. This challenge is going to read like a math problem, so buckle up and hold on. Raunaq, Jean, Eric, Yogesh and Sally took a plane trip to Osaka. Raunaq and Eric had the vegetarian dinner. They rest had the fish dinner. Unfortunately, the fish was bad and made everyone sick. Using a set, print out the people who at the fish. Pause the video now and try it out.
How’d that challenge go for you? Feel free to follow along if you got stuck. Here I have DartPad open. I’m first going to define a set of all the passengers.
var passengers = { 'Raunaq', 'Jean', 'Eric', 'Yogesh', 'Sally'};
Next, I’m going to define another set that contains both Raunaq and Eric.
var veggie = { 'Raunaq', 'Eric' };
Now, let’s get a set of sick passengers. We do this using the difference method.
var sickPassengers = passengers.difference(veggie);
Now let’s print out the list. I could use the print statement, but I’m going to iterate through the list:
for (var passenger in sickPassengers) {
print(passenger);
}
And look at that - we have our sick passengers. Nice work.