I have worked on this for many hours trying to solve it on my own but I came to the conclusion that I need help after several hours of hitting a dead end. I know very close but can't get rid of the spaces between words. here is my code:
function rot13(encodedStr) {
var codeArr = encodedStr.split("");
var decodedArr = [];
var letters = ["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"];
var space = " ";
var location = 0;
var temp = [];
for(var i = 0; i<codeArr.length; i++){
if(letters[i] !== " "){
location = letters.indexOf(codeArr[i]);
decodedArr.push(letters[(location+13)%26]);
}else
decodedArr.push(letters[i]);
}
return decodedArr.join("");
}
rot13("SERR CVMMN!");
This is supposed to return "FREE PIZZA!"