Error when submit but the code work well

I was making the challenge in with the help of runjs to see the results in real time and when I finish, I submit, but not pass the challenges, but in chrome and in run.js with the same strings the code work.
I got error for all given strings, but Idk what is the mistake.

At right you can see the evaluations of the function and the string and all results are true.

This is my code:


function rot13(str) {
str = str.split("")
const dictionary = ["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"]
const cypher = []
const evaluar = /^[A-Za-z]+$/
for(let l in str){
  if(str[l].match(evaluar)){
    index = dictionary.indexOf(str[l])
    number = index + 13 >= 26 ? index - 13 : index + 13
    cypher.push(dictionary[number])
  }else{
    cypher.push(str[l])
  }
}
return cypher.join("").toString();
}
  **Your browser information:**

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36

Challenge: Caesars Cipher

Link to the challenge:

After adding console.log(rot13("SERR PBQR PNZC")); at the end of code, you will see couple ReferenceErrors. Editor runs in strict mode, so variables needs to explicitly declared.

1 Like

Thanks! I didn’t consider that. Thanks!