Solución
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