javascript count words in array code example
Example: word count algorithm javascript
function getWordCount() { let map = {};for (let i = 0; i < array.length; i++) { let item = array[i]; map[item] = (map[item] + 1) || 1; } return map;}getWordCount(array); // { apple: 3, orange: 2 }