Advertisement
nikolayneykov

Untitled

May 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve ([str]) {
  2.   let words = {}
  3.  
  4.   str
  5.     .split(/\W+/)
  6.     .filter(x => x)
  7.     .forEach(x => (words[x] = words[x] + 1 || 1))
  8.  
  9.   console.log(JSON.stringify(words))
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement