title: Javascript + build a dynamic variable name from a variable name and string
body: <p>I'm not clear on the correct syntax to do the following.</p>
  
  <ul>
  <li>I have tried eval() I have tried [] and {[]} as well..</li>
  </ul>
  
  <p>I start with this:</p>
  
  <pre><code>var player1InitStart = 0;
  var player2InitStart = 0;
  var player3InitStart = 0;
  var player4InitStart = 0;
  
  var playerID =  event.target.id; // will return, player1, 2, 3, 4
  </code></pre>
  
  <p>To be used in a check like so:</p>
  
  <pre><code>if(eval(playerID + "InitString") == 0){
      //do something, first time starting video
      eval(playerID + "InitString") = 1;
      alert('First Time Playing Video' + eval(playerID + "InitString"));
  }
  </code></pre>
  
  <p>I am trying to use the playerID value together with the string: "InitStart".. </p>
  
  <p>so I can then update the target xxInitStart variable above.</p>
  
  <p>How can I concatenate the var playerID with the string InitStart so I can now target one of the playerXInitSTart variables to update it?</p>
  
  <p>Update:  answer/solution that worked for me-</p>
  
  <ul>
  <li>no clue why the $ character is being used?  (reminds me of PHP)</li>
  <li><p>no clue why the back tick marks '<code>' are there either? '</code>'</p>
  
  <p>var playerID =  event.target.getIframe().id;
  var targetInitID = <code>${playerID}InitStart</code>;</p>
  
  <p>//access (get or set)
  alert(window[targetInitID]);
  window[targetInitID] = 1;</p></li>
  </ul>