Hello, we will solve another problem from Freecodecamp and this problem was also shared with other programming languages. But today we will use the Javascript my favorite language :)\n\nHere’s the question from Freecodecamp:\n\nOne of the simplest and most widely known ciphers is a Caesar cipher, also known as a shift cipher. In the shift cipher ROT13 cipher meaning of the letters is shifted by some set amount.\n

A common ROT13 cipher, where the values of the letters are shifted by 13 places. Thus ‘A’ ↔ ‘N’, ‘B’ ↔ ‘O’ and so on.

\n

Write a function which takes an ROT13 encoded string as input and returns a decoded string.

\n

All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.

\n

Please see my solution below:

\n\n

function rot13(str) { // LBH QVQ VG!\n  var splitChar = str.split("");\n  var encodedChar = [];\n  var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM".split("");\n \n  for(var x = 0; x<splitChar.length ;x++ )\n    {\n      if(alphabet.indexOf(splitChar[x]) === -1)\n         {\n           encodedChar.push(splitChar[x]);\n         }\n      else \n      {\n        for (var y = 0 ; y <alphabet.length ; y++)\n          {\n            if(splitChar[x]===alphabet[y])\n              {\n                encodedChar.push(alphabet[y + 13]);\n              }\n          }\n      }\n    }\n  \n // return alphabet;\n  return encodedChar.join("");\n}\n\n// Change the inputs below to test\nrot13("ABCDEFGHIJKLMNOPQRSTUVXYZ");

\nHappy coding :)!\n

\n