Cofounded Host Collective (DiscountASP.net). Cofounded Player Axis (Social Gaming). Computer Scientist and Technology Evangelist with 20+ years of experience with JavaScript!
// Note: this function (like the original) does not take into consideration a tie.constcharCountHashTable=(str='')=>Array.prototype.reduce.call(str,(acc,x)=>{// increment countacc.count[x]=~~acc.count[x]+1// set 'most' to larger valueacc.most=acc.count[x]>~~acc.count[acc.most]?x:acc.mostreturnacc},{count:{},most:null})charCountHashTable('lollipop')//=> { count: { l: 3, o: 2, i: 1, p: 2}, most: 'l' } }
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
A solution using reduce: