Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. const array = [ 'NORTH', 'SOUTH', 'SOUTH', 'EAST', 'WEST', 'NORTH', 'WEST' ]
  2. const count = array.sort().reduce((counter, item) => {
  3. counter[item] = counter.hasOwnProperty(item) ? counter[item] + 1 : 1;
  4. return counter;
  5. }, {})
  6. console.log(count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement