Created
July 22, 2017 00:36
-
-
Save davidryanhuff/c78735ed995b28ffd8e8af45ffa04334 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment