title: charCodeAt() - Cannot read property 'length' of undefined
body: <p>I need some advice to use charCodeAt() method.</p>
  
  <p>My codes are below:</p>
  
  <pre><code>doParity() {
  var str = ["abcd", "efgh", "ijkl"];
  var arr = str[0][0] + str[1][0] + str[2][0];    // arr = "aei"
  
  var bin = [];
  var par = [];
  var parity;
  var result = [];
   // line 8
   for (let j = 0; j &lt; 3; j++) {
     bin[j] = this.toBin(str[j][0]);      // bin[j] is 8bit binary number
     par[j] = bin[j][0];                  // when j=0, str[j][0] = 'a',
                                          //           bin[j] = 01100001,
                                          //           par[j] = 0 
     if (j == 0) parity = par[j] ^ par[j + 1];
     else parity ^= parity[j + 1];
     alert(parity);
   }
  //line 18
  //for (let i = 0; i &lt; 8; i++) {
  //  for (let j = 0; j &lt; 3; j++) {
  //    bin[j] = this.toBin(str[j][i]);
  //    par[j] = bin[j][i];
  //    if (j == 0) parity = par[j] ^ par[j + 1];
  //    else parity ^= parity[j + 1];
  //  }
  //  result[i] = parity;
  //}
  //alert(result);
  }
  
  toBin(str) {           // This function get ASCII value and return 8bit binary number of it. 
    var st, i, j, d;
    var arr = [];
    var len = str.length;
    for (i = 1; i &lt;= len; i++) {
    //reverse so its like a stack
      d = str.charCodeAt(len - i);
      for (j = 0; j &lt; 8; j++) {
        arr.push(d % 2);
        d = Math.floor(d / 2);
      }
    }
    //reverse all bits again.
    return arr.reverse().join("");
  }
  </code></pre>
  
  <p>The Line8's for loop works well, then I coded the Line18's loop because I need to get 8bit xor variables, however it doesn't work.</p>
  
  <p>It gives me <img src="https://i.stack.imgur.com/1xh45.png" alt="this error">.</p>
  
  <p>This code is very simple, but I'm still wandering.</p>
  
  <p>Any help would be appreciated.</p>