Type error read only

Tell us what’s happening:

Your code so far

function rot13(str) { // LBH QVQ VG!
  
  var any_str =str.split(' ');
  var temp ;
  var new_str="";
  var char;
  for(i=0;i<any_str.length;i++)
  {
    for(j=0;j<any_str[i].length;j++)
      {
        temp=any_str[i].charCodeAt(j)-13;
        char =  String.fromCharCode(temp);
        
        any_str[i][j] = char ;
      }
  }
  return any_str;
}

// Change the inputs below to test
rot13("SERR PBQR PNZC");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0.

Link to the challenge:
https://www.freecodecamp.org/challenges/caesars-cipher

i am getting an error here ,because i want to change each character of the string but it is showing me type error read only 0

You can only change the whole string, not just one character inside it.

then how could i change each character one bye one?

You could split the string into an array and then change them one by one.

i already splitted the string into an array ,now my array consist [“SERR, PBQR, PNZC”] but i want to change every character and make a cipher

And you can split those words (SERR, PBQR, PNZC) into arrays as well.

you mean i should again split those array elements into another arrays of character?

Yes, so that you get: [["S", "E", "R", "R"],[...],[...],[...]]

ohkk thanx so much :slight_smile: