title: HTML JS assembling array name works fine but then prints as a "string" rather than the actual job
body: <p>I am doing a bit of prelim coding for a game with robots. </p>
  
  <p>I have written a short program in JavaScript to track turns and player in the game.
  I can update the turns, return whose turn it is no problem.</p>
  
  <p>I want to use arrays to hold info about players. I'm learning at the moment so for now I'm using an array with only 2 elements.</p>
  
  <p>The names are <code>player1_data</code>, <code>player2_data</code>, etc. I want to find out the content of array element 0, so it becomes player1_data[0], which is fine.</p>
  
  <p>If I type this in all is fine and I get my element returned to me.</p>
  
  <p>However, if I assemble the array info, by going "player" + current_player + "_data[" + element +"]" then it looks fine, but simply doesn't not function.</p>
  
  <p>It just a string of characters, not the actual array element request that I get if I type it in manually!</p>
  
  <p>What is the problem?</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
  &lt;html&gt;
    &lt;head&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;button class="button" onclick="vardisplay(), updateturn() "&gt;SHOW VARIABLES&lt;/button&gt;
  
  
      &lt;p id="para1"&gt;false&lt;/p&gt;
      &lt;p id="para2"&gt;2&lt;/p&gt;
      &lt;p id="para3"&gt;2&lt;/p&gt;
      &lt;p id="para4"&gt;2&lt;/p&gt;
      &lt;p id="para5"&gt;2&lt;/p&gt;
      &lt;p id="para6"&gt;2&lt;/p&gt;
      &lt;p id="para7"&gt;2&lt;/p&gt;
      &lt;p id="para8"&gt;2&lt;/p&gt;
  
      &lt;script&gt;
  
        var ifselect = 0
        var current_turn = 0
        var last_turn = 0
        var players_in_game = 5
        var current_player = 1
  
        var current_robot = 123
        var player_id = "player" + current_player + "_data";
  
        var arrayselector = 0
        var player_array_display = player_id + "[" + arrayselector + "]";
  
        var player1_data = ["dave", current_robot];
        var player2_data = ["kim", current_robot];
        var player3_data = ["nigel", current_robot];
        var player4_data = ["bob", current_robot];
  
        function updateturn() {
  
          if (current_player &gt; players_in_game - 1) {
            current_player = 1
            current_turn = current_turn + 1
  
          } else {
            current_player = current_player + 1;
            player_id = "player" + current_player + "_data";
            player_array_display = player_id + "[" + arrayselector + "]";
          }
        }
  
        function vardisplay() {
  
          document.getElementById("para1").innerHTML = "random stuff";
          document.getElementById("para2").innerHTML = "players_in_game:     " + players_in_game;
          document.getElementById("para3").innerHTML = "current_turn:     " + current_turn;
          document.getElementById("para4").innerHTML = "current_player:  " + current_player;
          document.getElementById("para5").innerHTML = "current_robot:     " + current_robot;
          document.getElementById("para6").innerHTML = "player_id:    " + player_id;
          document.getElementById("para7").innerHTML = "player_array_display:     " + player_array_display;
          document.getElementById("para8").innerHTML = player2_data[0];
  
        }
  
  
      &lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>