I have given array of strings and I'd want to make map which will have those strings as keys and values will be how many times each string is present in the array. The problem is I can't really increment value, which was once added to the map. It's my code:
for(let str of data) {
if(map.has(str)) map[str] = map.get(str) + 1;
else map.set(str, 1);
}
But it doesn't work as intended. I tried map[str]++ etc. but nothing worked for me...