Solución
solution.tsTypeScript
export function mostFrequentChar(text: string): string {
let mapper = new Map<string, number>()
let arrs= text.split('')
for(let arr of arrs){
if(mapper.has(arr)){
mapper = mapper.set(arr, mapper.get(arr)! + 1)
} else {
mapper = mapper.set(arr, 1)
}
}
let maxCount = 0
let maxChar = ''
for(let [char, count] of mapper){
if(count > maxCount){
maxCount = count
maxChar = char
}
}
return maxChar;
}0respuestas