I have a javascript array where, for each iteration, a name is added to the end using the push feature. I'm sending this array to a html file where it will be displayed. Currently displaying this array after all iterations have completed gives:
John, Smith, Paul, Doe
However, I wish the array to be displayed vertically like:
John
Smith
Paul
Doe
In Javascript, is there some way to specify for each name to be entered as a new row in the array? In Matlab you can easily specify which row or column you want data to be stored in the array but I am yet to find a simple approach in Javascript.
Thank you for any help you might be able to give me!
UPDATE: Javascript (simplified):
port.onMessage.addListener(function(msg) {
var Array = []
var Names = ["John", "Smith", "Paul", "Doe"]
for (var p = 0; p < Names.length; p++) {
Array.push(Names[p])
}
document.getElementById('status').textContent = Array;
});
HTML (simplified):
<html>
<head>
<script src="Javascript.js"></script>
<style type="text/css" media="screen">
body {
min-width : 400px;
min-height : 300px;
text-align : right;
background-color: #D0D0D0; }
#status {
font-size : 10px;
color : #0000CC;
text-align : left;
font-family : "Times New Roman", Times, serif; }
</style>
</head>
<body>
<div id="status"></div>
</body>
</html>