I am trying to get the number of times each string item occurs in an array and print it out using a Map. I am basically reading in the data from firebase functions, but for now, I am using an array to test the code to get the occurrences of each item. I tried the following code from here, but it does not work and I am not sure why:
<script>
var appVersion= ["5012", "5021", "5012", "5011", "5012", "5021"];
var count = new Map();
appVersion.forEach(version=> count.set(count.get(version) + 1));
function show(versions) {
document.write(versions);
document.write("<br>");
}
count.forEach(show);
</script>
Any help or advice will be highly appreciated.