Solución
solution.tsTypeScript
export function mostFrequentChar(text: string): string {
let counter = {};
for(let i = 0; i < text.length;i++){
const char = text[i];
if(counter[char]){
counter[char] += 1;
} else {
counter[char] = 1;
}
}
let max = 0;
let mostFrequent = ''
for(let key in counter) {
const value = counter[key];
if(value > max){
max = value;
mostFrequent = key;
}
}
return mostFrequent;
}0respuestas