I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
That would be done with either a for loop or the Array’s .forEach method. Pseudo-code with a for loop could look like this:
let map = {};
for (let i=0; i<arr.length; i++){
// if arr[i] is a property(key) on the map object, increase that value by 1
// else, create that property (key) on the map object and set it to 1
}
return map;