How to get how many times there is a matching value?
Given an array: Given that the following gets the current svg path property (I am using leaflet map, so this value is in the json ). I run the following which I found on this answer, basically when I mouse hover a polygon, I get countryName and I check how many times is within that array: But if I do: console.log(result); it always gives me 1 or 0 if no match. In the real scenario an example of console.log(nationList); gives: UDPATE What i did before was to try to count each value: That's fine as it gives me for example: Austria: 22 But when I do: Each time I mouse hover a path with a property name , lets say Austria , even tho within the array we have many repeating occurrences, the console gives me 1 if a match is there or 0 The code that you have posted seems to be working correctly, but as GetOffMyLawn stated you should compare the two as the same case just to be sure. Sorry for the short answer, but not enough reputation at the moment to just post comments. The below...