Tell us what’s happening:
I have gotten this far. I am able to convert the values to their respective Rot13 values. But I cannot work with the Spaces between the “Free Code Camp” and the special characters in other tests.
I need someone to help me with it.
Your code so far
function rot13(str) { // LBH QVQ VG!
let result = [];
let test = str.split("");
console.log(test);
let arr = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
let testArr = arr.slice();
console.log(arr);
let arr2 = [];
for (var i = 0; i < 13; i++) {
arr2.push(arr[i+13]);
}
arr2 = arr2.concat(testArr.splice(0, 13));
console.log(arr2);
test.map(function(item) {
for (var j = 0; j < arr.length; j++) {
if (item == arr[j]) {
result.push(arr2[j]);
}
}
return result;
})
return result;
}
// Change the inputs below to test
rot13("SERR PBQR PNZC");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/caesars-cipher