title: How to create a <a> link dynamically from a javascript array inside a script tag?
body: <p>I am trying to create a 3  link with href and innerHTML from a JS array which is declared outside of the script tag. I am not sure how to pass the array into the script tag and use to create custom  elements.
  Here is my JS array</p>
  <pre><code>
      let linkArr = [
          {
              &quot;name&quot;: &quot;A sample URL&quot;, &quot;url&quot;: &quot;https://asampleurl.com&quot;
          },
          {
              &quot;name&quot;: &quot;Another sample URL&quot;, &quot;url&quot;: &quot;https://anothersampleurl.com&quot;
          },
          {
              &quot;name&quot;: &quot;A final sample URL&quot;, &quot;url&quot;: &quot;https://afinalsampleurl.com&quot;
          }
      ]
  
  </code></pre>
  <p>Here is what I am trying
  '''</p>
  <pre><code>&lt;script link1Name=this.links[0].name, link1Href= this.links[0].url&gt;
  
      var a = document.createElement(&quot;a&quot;);
      var link1Name = document.currentScript.getAttribute('link1Name');
      var text = document.createTextNode(link1Name);
      a.appendChild(text);
      a.href = link1Href ;
      var element = document.getElementById(&quot;links&quot;);
      element.appendChild(a);
          
  &lt;/script&gt;
  </code></pre>
  <p>'''</p>