Answers for "how to display an array in html"

0

how to display an array in html

<p id="display-array"></p>
<script type="text/javascript">
  // array to be displayed
  var array = [1, 2, 3, 4, 5];
  // access the textContent of the HTML element and set it to the
  // value of the array seperated with a comma and a space
  document.getElementById("display-array").textContent = array.join(", ");
</script>
Posted by: Guest on July-16-2021

Code answers related to "how to display an array in html"

Browse Popular Code Answers by Language