title: How to append object value using for loop in javascript?
body: <p>I loop through an array called accData and make a new array called WL and RF. I want to make it easy to maintain, but I have a problem. When I want to change the WL array data to CH2 and RF array data to DIG2, I have to type the script manually.
  This is my script</p>
  
  <pre><code>const accData = [
      { st: 'serijabo', path: 'serijabo.json', wl: 'CH1', rf: 'DIG1' },
      { st: 'sukabumi', path: 'sukabumi.json', wl: 'CH2', rf: 'DIG2' },
  ];
  
  for (let i = 0; i &lt; accData.length; i++) {
    const xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function () {
    if (xhr.readyState === 4) {
      const data = JSON.parse(xhr.responseText);
  
      let WL = [];
      let RF = [];
      for (let i = 0; i &lt; data.length; i++) {
        WL.push(Number(data[i].CH1)); // this line
        RF.push(Number(data[i].DIG1)); // and this line
      }
    }
   }
  }
  </code></pre>
  
  <p>I try to use ES6 template to solve it but it is not working because the template must be place in a string.</p>
  
  <pre><code>WL.push(Number(data[i].`${accData[i].wl}`)); //not working
  RF.push(Number(data[i].`${accData[i].rf}`)); //not working
  </code></pre>
  
  <p>How can I solve this?</p>