title: How to call a variable when its name is equal to a string?
body: <p>So we have some HTML here: </p>
  
  <pre><code>  &lt;div class="button galleryButton" number="1"&gt;Gallery&lt;/div&gt;
    &lt;div class="button galleryButton" number="2"&gt;Gallery&lt;/div&gt;
  </code></pre>
  
  <p>And two arrays:</p>
  
  <pre><code>      var room1 = [
          {
            src: './includes/imgs/Hotel/tea.JPG',
            w: 700, // Those are just width and height 
            h: 300 //
          },
          {
            src: './includes/imgs/Hotel/00039850.JPG',
            w: 600,
            h: 400
          }
        ];
  
        var room2 = [
          {
            src: './includes/imgs/Hotel/somethingElse.JPG',
            w: 700,
            h: 300
          },
          {
            src: './includes/imgs/Hotel/00039840.JPG',
            w: 600, 
            h: 400 
          }
        ];
  </code></pre>
  
  <p>We pick these buttons with </p>
  
  <p><code>var roomCounter = document.getElementsByClassName('galleryButton');</code></p>
  
  <p>And we loop through them so we can hold the selected room number in a variable </p>
  
  <pre><code>for (var i = 0; i &lt; roomCounter.length; i++) {
    roomCounter[i].addEventListener("click", function(){
        var roomNumber = this.getAttribute("number");
        var thisRoom = 'room'+roomNumber;
  </code></pre>
  
  <p>So lets say we click on the first button:<br>
   <code>thisRoom</code> now stores 'room1' string<br>
  (PhotoSwipe is a cool javascript gallery and 'thisRoom' should be an array of images in order to make it work.)
  But here comes:</p>
  
  <pre><code>var newGallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, thisRoom, options);
  </code></pre>
  
  <p>It wont work, because it takes a simple string 'room1' instead of an array held in a variable.</p>
  
  <p><strong>How can I make newGallery know that I want it to take an array equal to the value of thisRoom, not just a string?</strong> </p>
  
  <p>And also, if you see something that you find 'not very clear', 'just horribly bad' in my code or think there is a better approach, I'd love to hear it! </p>