Caesars Cipher BUG - working code is not passing trough

Caesars Cipher BUG - working code is not passing trough
0

#1

Hi! I have written a code which solves a freeCodeCamp Ceasars Cipher task, but it is not accepted by onsite system. Am I doing something not correct or is it freeCodeCamp bug?

Your code so far

function rot13(str) { // LBH QVQ VG!
var words = str.split(' ');
var decoded = '';
var uniCode = [];
var letterCode = [];
var rootUniCode = [];
for (i = 0; i < words.length; i++){
  var oneWord = words[i];

  for (j = 0; j < oneWord.length; j++) {
    rootUniCode = oneWord.charCodeAt(j);
    //console.log(rootUniCode);
    //deocding
    if (rootUniCode >= 65 && rootUniCode <= 90) {
      letterCode = oneWord.charCodeAt(j) + 13;
      if (letterCode > 90) {
        letterCode = 64 + (letterCode - 90);
      }
      uniCode.push(letterCode);
    } else if (rootUniCode < 65 || rootUniCode > 90) {
      uniCode.push(rootUniCode);
    }

  }
  uniCode.push(32);
  decoded = String.fromCharCode.apply(String, uniCode);
}

  console.log(decoded);
  return decoded;
}
rot13("SERR PBQR PNZC");
rot13("SERR CVMMN!");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:54.0) Gecko/20100101 Firefox/54.0.

Link to the challenge:


#2

Your strings have an extra space in the end which shouldn’t be there.


#3

yes! you were right. thanks for help :slight_smile: