Type error read only

Type error read only
0

#1

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:


#2

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


#3

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


#4

then how could i change each character one bye one?


#5

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


#6

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


#7

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


#8

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


#9

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


#10

ohkk thanx so much :slight_smile: