Caesars Cipher using javascript arrow functions

Here we will take ROT13 encoded string as input and returns a decoded string.

//Caesars Cipher using javascript arrow functions

function rot13(str) {
  return str.replace(/[A-Z]/g, L => String.fromCharCode((L.charCodeAt(0) % 26) + 65));
}

console.log(rot13("Gur dhvpx oebja sbk whzcf bire 13 ynml qbtf.")); 
console.log(rot13("LYrneavat jvgu Znawrrg")); 

Leave a Comment

Your email address will not be published. Required fields are marked *