I have an array called carArray which is an array of Cars.
How can I write a function to determine if the array contains a specific model? For example if a user inputs "BMW", how can I determine if that is in the array? I am trying to avoid answering this problem with writing a for loop to loop through the entire array each time this happens.
struct Car {
var make: String?
var model: String?
var year: Double?
}
var carArray: [Car] = []
carArray.append(Car(make: "Audi", model: "S5", year: 2015))
carArray.append(Car(make: "BMW", model: "X3", year: 2016))
carArray.append(Car(make: "Honda", model: "Accord", year: 2018))