Tell us what’s happening:
upon trying to run my code, i get the error " TypeError: Cannot assign to read only property ‘0’ of string ‘SERR PBQR PNZC’".
This error prevents me from seeing the console.log prints.
Can anyone explain what is causing this problem?
**Your code so far**
function rot13(str) {
var key="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for(var i=0;i<=str.length;i++){
for(var j=0;j<=key.length;j++){
if(str[i]===key[j]){
if(j+13>key.length){
str[i]=key[j - 13];
}
else{
str[i]=key[j + 13];
}
}
}
}
console.log(str);
return str;
}
rot13("SERR PBQR PNZC");
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.81 Safari/537.36 Edg/104.0.1293.47
Challenge: JavaScript Algorithms and Data Structures Projects - Caesars Cipher
Link to the challenge: