Learn JavaScript. How to display an array, in the current window, in a div?

Here’s the source code:

<div id = "div_array"></div>

<script>
var letters_array = ['a', 'b', 'c', 'd'];

var div_array_value = '';
for (var i = 0; i < letters_array.length; i ++) {
  div_array_value = div_array_value + letters_array [i] + '<br>';
}

document.getElementById ('div_array').innerHTML = div_array_value;
</script>

Software used in the demo:
LUNLUN44 (version 2018.02.09): http://LUNLUN.COM/44
Mozilla Firefox (version 62.0.3): https://www.mozilla.org/en-US/firefox/new/

Leave a Reply