word count algorithm javascript
snippet in javascript

word count algorithm javascript

user9599

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 }