I have the following Array
[{cityName: "Gauteng"}, {cityName: "cape town"}, {cityName: "Durban"}]
I am trying to check if a value matches "cityName" in any of the objects .eg I have a set value as "Durban" and it should return true as Durban exists in on of the objects
My attempt is below however I am getting a false value even if the cityName exists
test() {
var x = this.getCities;
var doesExist = x.some((el) => { el.cityName === "Durban"});
console.log(doesExist);
}
{ el.cityName === "Durban"}should be{ return el.cityName === "Durban"}or can be just `el.cityName === "Durban". You are very close :-)