diff --git a/README.md b/README.md index 0b4a10c..e95954e 100644 --- a/README.md +++ b/README.md @@ -473,6 +473,14 @@ el.addEventListener('click', myClickHandler, { }); ``` +# Most frequent element in an array. +```javascript +const mostFrequent = arr => + Object.entries( + arr.reduce((a, v) => { + a[v] = a[v] ? a[v] + 1 : 1; + return a; + }, {}) + ).reduce((a, v) => (v[1] >= a[1] ? v : a), [null, 0])[0]; - - +```
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: