Given this:
var results = [
{
"Title": "Battle of Baekgang",
"Space": ["South Korea"]
},
{
"Title": "Victory Tests",
"Space": ["United Kingdom"]
},
{
"Title": "Everett massacre",
"Space": ["United States"]
},
{
"Title": "Bologna massacre",
"Space": ["Italy"]
},
{
"Title": "Milano massacre",
"Space": ["Italy"]
}
];
How would I loop it in order to say:
If Space value matching myNation {do this}?
Having set var countries = ["Italy", United Kingdom", "South Korea"];
I have var regex = new RegExp(countries.join("|"), "i");
And I know i could do if(location.match(regex)) {
But I need to first store location I guess as the name of Space value
Or any other/better way?
UPDATE
I have a map with polygons and each polygons have classes like:
<path class="italy france germany">
I could have Nclasses names for each country, the json I get would have one object called Space with one or more countries in it, so I'd need to check if any of the json countries, matches any class in any polygons paths on my map and if so, the path should get a class active added to it.
"Space"value is matching one of the countries inmyNation?