Solución

@jessusthread_d654f577·9/10/2026TypeScript
solution.tsTypeScript
export function isPalindrome(text: string): boolean {
  const cleanText: string = text.trim().toLocaleLowerCase();

  let isWordPalindrome: boolean = true;
  let countInitialIndex: number = 0;

  if (cleanText === '' || cleanText.length === 1) return true;

  const lengthText: number = cleanText.length - 1;

  for (let i = lengthText; i >= 0; i--) {
    const firstLetter: string = cleanText[countInitialIndex];
    const lastLetter: string = cleanText[i];

    if (firstLetter !== lastLetter) return false;

    countInitialIndex++;
  }

  return isWordPalindrome;
}
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.