Solución

PA@pablo2310allendes_199ea37e·8/7/2026TypeScript
solution.tsTypeScript
export function rot13(text: string): string {
  // Escribe tu solución aquí
  let abcedario = 'abcdefghijklmnopqrstuvwxyz'
  const alphaArray = abcedario.split('')
  return text.split('').reduce((acc,curr)=>{
    const index = (alphaArray.indexOf(curr.toLowerCase()) + 13 ) % alphaArray.length
    if(alphaArray.indexOf(curr.toLowerCase()) === -1){
      acc+= curr
    }else if(curr === curr.toUpperCase()){
      acc += alphaArray[index].toUpperCase()
    }else{
      acc += alphaArray[index]
    }
    return acc
  },'')
  
}

console.log(rot13('Hello'))
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.