Cipher project working but FCC not approving it

I made my Caesar Cipher project and it’s working completely fine, doing what it is supposed to, even though the FCC algorithm doesn’t approve it. Is there something wrong with the code, the input or it’s just an intern error of fcc?

  **My code so far**

function rot13(str) {
  let newStr = []

  str.split('').map(char => {
    let newChar = undefined

    if (/\W/g.test(char) || /\d/g.test(char)) {
    } else if (/([A-Z])/g.test(char)) {
      newChar = (((char.charCodeAt(0) - 'A'.charCodeAt(0)) + 13) % 26) + 'A'.charCodeAt(0)
    } else if (/([A-Z])/g.test(char)) {
      newChar = (((char.charCodeAt(0) - 'a'.charCodeAt(0)) + 13) % 26) + 'a'.charCodeAt(0)
    } else {newStr.push(char)}


  return newStr.join('');

console.log(rot13("SERR YBIR?"))

  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36

Challenge: Caesars Cipher

Link to the challenge:

Nope, it’s your code. Log everything to the console and look at the browser console (not the console area of the editor; this is the problem) and you’ll see:


The weird symbols indicate your inserting weird characters; they’re little rectangles in chrome, which I believe are null strings that your code is inserting due to this:

Since you are catching all possibilities you should with the conditional, anytime some junk is found, you’re calling String.fromCharCode(undefined); and pushing the result into the string. You can’t see it since it’s the null character, but it’s there and failing the test’s assertions.

1 Like

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