JavaScript Algorithms and Data Structures Projects - Caesars Cipher

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) {

for(var i=0;i<=str.length;i++){
  for(var j=0;j<=key.length;j++){
        str[i]=key[j - 13];
        str[i]=key[j + 13];

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:

Strings are immutable. You cannot change individual characters in a string

1 Like

Thank you for your help! With this information, I was able to solve the challenge.

1 Like

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