1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 1x 2x 2x 11x 11x 65x 2x | module.exports = { countNum: (str) => { const e = []; const a = [...new Set(str.replace(/\s+/g, '').split(''))].map((row) => { const reg = new RegExp(row, 'g'); return { key: row, value: str.match(reg).length }; }); a.map(row => row.value === Math.max(...a.map(row => row.value)) ? e.push(row.key) : null); return e; }, } |