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 =
schedule.join("<br>");
Example print array on separate lines in JavaScript
Simple example code.
<!DOCTYPE html>
<html>
<body>
<div id="output">
<div>Extracting...</div>
</div>
<script>
var arr = ["100", "200", "300"];
document.getElementById("output").innerHTML =
arr.join("<br>") + "<br>";
</script>
</body>
</html>
Output:
![JavaScript print array on separate lines](https://i0.wp.com/tutorial.eyehunts.com/wp-content/uploads/2022/02/JavaScript-print-array-on-separate-lines.jpg?resize=227%2C127&ssl=1)
How can I print multiple arrays on separate lines using the same console.log?
var a = [2, 4];
var b = [5, 6];
console.log('',a,'\n',b)
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