@anonymous/

DesertedPiercingAmpersand

JavaScript

No description

fork
loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function rot13(str) {
  for (var i = 0; i < str.length; i++) {
    // for regex, use the match or replace function!
    if (str[i].match(/[A-Z]/g)) {
        var char = str.charCodeAt(i) + 13;
        str[i] = String.fromCharCode(char < 90 ? char : 64 + (char % 90));
        console.log(String.fromCharCode(char < 90 ? char : 64 + (char % 90)) + "  |   " + str[i]);
    }
  }
  
  return str;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");
Native Browser JavaScript