Solución

@rosasruizlg_970dbfcc·23/9/2026TypeScript
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
Respuestas

Aún no hay respuestas

¡Sé el primero en responder!

Escribir un comentario

Recuerda ser amable. Estás comentando la solución de otra persona. Comparte tu perspectiva de forma constructiva y respetuosa.

Debes iniciar sesión para publicar un comentario.