GREGG-CHRISTOFFERSON
4/12/2018 - 12:42 AM

freeCodeCamp Ceasars Cipher

//I have to charCodeAt str i indexOf then add 13. then string from charCode using new number?
function rot13(str) { // LBH QVQ VG!
var array = str.split(" ");  
var key = ["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 key1 = {
  "A": [0],
  "B": [1],
  "C": [2],
  "D": [3],
  "E": [4],
  "F": [5],
  "G": [6],
  "H": [7],
  "I": [8],
  "J": [9],
  "K": [10],
  "L": [11],
  "M": [12],
  "N": [13],
  "O": [14],
  "P": [15],
  "Q": [42],
  "R": [43],
  "S": [44],
  "T": [45],
  "U": [46],
  "V": [47],
  "W": [48],
  "X": [49],
  "Y": [50],
  "Z": [51]
};  
// var count = 0;
// while(count < 14){  
// key = key.concat(key); 
// count++;
//   }
var newArray=[];
  for(i=0;i<str.length;i++){
  for(j=0;j<key.length;j++){
    if(str[i] == key[j]){
    if(key.indexOf(key[j])<13){  
    var index = key.indexOf(key[j])+13;
            newArray.push(key[index]);
      } 
      else {
        var index = 
      }
//       str[i] = key[index];
//       return key[index];
//       return key[index];
    }
  }
}  
// var newArray = array.join(" ");  
// return str[0];  
//   return key.indexOf("A");
  return newArray;
}

// Change the inputs below to test
rot13("NERR PBQR PNZC");