Caesars Cipher - other approaches?

My code is very similar to yours, as all beginners are since we only know if statements.

I have seen 3 line solutions which i don’t understand:

–> freeCodeCamp Algorithm Challenge Guide: Caesars Cipher

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