const getMostCommonSymbol = (str) => {
const sortedSymbols = str.split('').sort().join('');
const countedSymbols = [...sortedSymbols.matchAll(/(.)\1*/g)];
return countedSymbols.reduce(
(acc, [row, symbol]) =>
acc.count < row.length ? { symbol, count: row.length } : acc,
{ symbol: null, count: 0 }
);
}
getMostCommonSymbol('asdasda')