Currently, I am utilizing the Google Maps API in Angular with TypeScript. My goal is to create a clickable map of countries that changes color when clicked. This task seems simple, but I am encountering a challenge due to the complexity of the ng2-google-maps library for Angular.
The issue at hand involves obtaining the index of the main object in an array. However, I need to perform this search based on a value that resides within another object in a separate array.
https://i.sstatic.net/K4EIc.png
After clicking on a region in the map, I am able to retrieve the country code, such as "PL" as shown in the console.log message.
My ultimate objective is to determine the index of the main array (where "PL" corresponds to index '0') in order to ascertain if the country code already exists within this array.
My initial attempt was as follows:
mainArray.findIndex((result) => result.c.findIndex((result) => result.v === 'PL'));
However, this approach did not yield the desired outcome. It seems that I may need to employ the slice() method to remove the identified index from the main array.
Thank you in advance for any assistance provided.