Roman 13 challenge help

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

This is from the Roman 13 code challenge.
Can anyone explain to me  why charCodeAt(0) in this case ?

Thanks for your help.

Because L is a string. It is a string of 1 character and you are getting the code of the first (and only in this case) character. Some languages have a separate data type for characters, but JS does not. In JS, the closest we have to a character is a string that is only one character long.

You do not need to pass anything to charCodeAt if you always just want the first character in the string (or if it is a single character string).

And maybe just a little clarification, L is a variable (argument), it contains the match.

function rot13(str) {
  return str.replace(/[A-Z]/g, match => {
    console.log(match); // L, B, H, Q, V, Q, V, G
    return String.fromCharCode((match.charCodeAt() % 26) + 65)

console.log(rot13('LBH QVQ VG!'));

Thanks guys for the help