Skip to content

JavaScript print array on separate lines | Example code

  • by

Use the join() method to combine the array into one string and separate each entry by <br> to print the array on separate lines in JavaScript.

document.getElementById("result").innerHTML =

Example print array on separate lines in JavaScript

Simple example code.

<!DOCTYPE html>

  <div id="output">


    var arr = ["100", "200", "300"];
    document.getElementById("output").innerHTML =
    arr.join("<br>") + "<br>";



JavaScript print array on separate lines

How can I print multiple arrays on separate lines using the same console.log?

var a = [2, 4];

var b = [5, 6];


Print array elements in a new line console

array = ["Bob", "James", "Taylor"]
for (i = 0; i< array.length; i++){
	console.log(array[i]) }

Do comment if you have any doubts or suggestions on this JS Array print topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *