Solución
solution.tsTypeScript
export function mostFrequentChar(text: string): string {
// Escribe tu solución aquí
interface FrequentChar {
[key: string]: number
}
let charTotalCount: FrequentChar = {};
let charCount = 0;
for(let char of text) {
if(!(char in charTotalCount)) {
charTotalCount[char] = charCount + 1;
}else if(charTotalCount[char]) charTotalCount[char] += 1;
}
return Object.keys(charTotalCount).reduce((max, key) => charTotalCount[key] > charTotalCount[max] ? key : max);
}0respuestas