Light Mode
Dark Mode
error test

my code is OK

but I see in console

10,43: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. 10,50: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.

assert.strictEqual(mostWanted("Lorem ipsum dolor sit amet"), "m");

this is my code, test "Lorem ipsum dolor sit amet" is OK

function mostWanted(text){
    let txt = text.toLowerCase().replaceAll(' ', '').
    replaceAll('!', '').replaceAll(',', '').replaceAll('.', '').split('').filter(el => isNaN(el));
    let ob = {};
    txt.forEach(
        el => {ob[el] = (ob[el] ?? 0) + 1;  }
    )
    return Object.entries(ob).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))[0][0];
}
Created: May 18, 2023, 3:04 p.m.
Updated: May 18, 2023, 3:04 p.m.
0
9
User avatar
2957549