title: JavaScript Use classList attribute to call internal variable
body: <p>I'm creating a basic typing game to help teach myself Thai typing and I'm breaking down the keyboard into sections (14 total).</p>
  
  <p>I'm using an onclick from HTML to call a function in my js file and that works great.  I pass 'thaiRightTop' from the initial onclick and the text loads fine.</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;a href="#" onclick="selector(thaiRightTop, className='thaiRightTop')"&gt;Thai Right Top&lt;/a&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>const thaiRightTop = ['ภ','ถ']
  
  function selector(ele, className){
          let textDisplay = document.querySelector('#textDisplay')
          textDisplay.innerHTML = ''
          textDisplay.classList = ''
          textDisplay.classList = className
          const words = createWords(ele, 3,5, 60)
          addSpan(words)
      }
  </code></pre>
  
  <p>However once the user has typed out the full string of words correctly I want to load another set of words using the same array.</p>
  
  <p>Where I'm confused and having issues is calling the same selector function from with JS and using the classList class name to call through the variable ele</p>
  
  <pre><code>if (correct === true){
      let textDisplay = document.querySelector('#textDisplay')
      className = textDisplay.classList
      selector(ele=className, className=String(className))
  }
  </code></pre>
  
  <p>I know I can define if/else if/switch case statement and hard code each array name (total of 14) but that seems like it's really redundant and unnecessary.  Is there an easy way to use a class name to refer to a const?</p>
  
  <p>Thanks in advance and apologies if this is a repeat question but I couldn't find anything anywhere else...</p>
  
  <p>Added a CodePen Link - Once the first sentence is completed I want to reload the the same set (thaiRightTop) which will create another random sequence of words.</p>
  
  <p>I created an IneffecientSelector to show what I didn't want to do but how it should work (sorry if I used codePen instead of SO Snippet, I'm more familiar with CP).</p>
  
  <p><a href="https://codepen.io/linusidom/pen/vYNowPb" rel="nofollow noreferrer">codePen Link</a></p>