Solution seems to work locally, but not on website

Tell us what’s happening:
I am running the tests locally and they all seem to pass, but they do not pass in the app. What is wrong with my code?

  **Your code so far**

function rot13(str) {
  let arrayifiedString = str.split('');

  for (var i = 0; i < arrayifiedString.length; i++) {
    thisCharCode = getCharCode(arrayifiedString[i]);
    console.log(thisCharCode);
    if (isCapitalLetter(thisCharCode) === true) {
      arrayifiedString[i] = getNewLetter(thisCharCode);
    }
  }

  return arrayifiedString.join('');

  function getCharCode(letter) {
    return letter.charCodeAt(0);
  }

  function isCapitalLetter(letterCharCode) {
    if (letterCharCode > 64 && letterCharCode < 91) {
      return true;
    }
    return false;
  }

  function getNewLetter(charCode) {
    if (charCode > 77) {
      return String.fromCharCode(charCode - 13);
    } else return String.fromCharCode(charCode + 13);
  }
}

console.log(rot13('GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.'));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36

Challenge: Caesars Cipher

Link to the challenge:

This variable is not declared.

In general, I recommend developing in ‘strict mode’.

Also, I recommend against using var.

It should show you ReferenceError: thisCharCode is not defined in the editor console, are you not seeing that?

As hinted at, the tests run in strict mode.

1 Like

huh… surprised node let me run this. But that is the problem.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.