title: How to add values from an array as textContent with JavaScript
body: <p>I'm having trouble figuring out how to add the values from an array as .textContent of a div.</p>
  <p>What I want to happen is if I receive an array (topics) I want the contents of the array to be set as the .textContent of the elements with class=&quot;tab&quot;.</p>
  <p>I feel like this code is correct, but doesn't seem to be working. Any ideas?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const Tabs = (topics) =&gt; {
    const tabsTopics = document.createElement("div");
    const tabsOne = document.createElement("div");
    const tabsTwo = document.createElement("div");
    const tabsThree = document.createElement("div");
  
    tabsTopics.classList.add("topics");
    tabsOne.classList.add("tab");
    tabsTwo.classList.add("tab");
    tabsThree.classList.add("tab");
  
    tabsTopics.appendChild(tabsOne);
    tabsTopics.appendChild(tabsTwo);
    tabsTopics.appendChild(tabsThree);
  
    document.querySelectorAll(".tab").forEach((el, i) =&gt; {
        el.textContent = topics[i];
      });
  
    return tabsTopics;
  }
  
  const topics = ['1', '2', '3'];
  
  document.getElementById('container').appendChild(Tabs(topics));</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="container"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>