Day four has been fantastic. I’ve gone through and recapped what I learned and got a sense of how data annotation are useful. Now it’s onto Checkpoint 2.
Here’s how far I got without help:
import UIKit // Checkpoint 2 challenge: Create an array of strings, then print the number of items in the array and also the number of unique items in the array. // My first stab at an array and counting how many items are in them // var family = ["Monica", "Joshua", "Ethan", "Hadley", "Joshua"] // print(family.count) // Great, got my count of 5, but for unique I'll need to use a set; I think. Then I'll need to use interpolation to print a comment that counts them both; I think. Let's truy. var family = Set(["Monica", "Joshua", "Ethan", "Hadley", "Joshua"]) print("The number of people in the family is \(family.count) and the unique number of names in the family is Y") // Here's what I think the problem means. I should create a set to find the unique values, and total value is supposed to be the same.
After watching the hint I think I need to come back to this tomorrow. What I THINK I’ll need to do, based on the hint..
// Define the family with an array that's also a constant let family = ["Monica", "Joshua", "Ethan", "Hadley", "Joshua"] // Define a set that includes the array so I can count it and see unique number. //Print a comment that interpolates the count of the original array and the set, so that I'll see a count of 4 (uniques) and 5 (totals)
I looked up the answer again, and it was immediately so obvious. I was so close and I just forgot how to add arrays into sets.