occurence count of each word

occurence count of each word

by 420

JavaScript

function repeat(str){
  let wordCount = {};
  const words =  str.toLowerCase().split(" ");
  words.map(item=>{
    wordCount[item] = wordCount[item] ? ++wordCount[item] : 1
  })
  return wordCount
}

console.log(repeat('My name is Sanjog Name and name'))