This string comparison is what happens in the following script. It iterates over the array of objects using the map array method and returns the index or false if the object does not exist in that position in the array. False values are filtered, and the array is counted. If the length is greater than zero then the index is again calculated and returned, otherwise -1 is returned.