Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const array = [ 'NORTH', 'SOUTH', 'SOUTH', 'EAST', 'WEST', 'NORTH', 'WEST' ]
- const count = array.sort().reduce((counter, item) => {
- counter[item] = counter.hasOwnProperty(item) ? counter[item] + 1 : 1;
- return counter;
- }, {})
- console.log(count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement