javascript freeCodeCamp Ceasars Cipher

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 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");

以上是关于javascript freeCodeCamp Ceasars Cipher的主要内容,如果未能解决你的问题,请参考以下文章

javascript freeCodeCamp Ceasars Cipher

javascript 从freecodecamp中获取的最大数量的数组

html JavaScript Calculator V1 - jQuery | FreeCodeCamp

javascript JS中的Palindrome https://www.freecodecamp.com/challenges/check-for-palindromes

FreeCodeCamp闯关

freeCodeCamp:Falsy Bouncer