I'm used to do this via php but now moving to js (newbie) and I can't see why it doesn't work!
Also please any suggestion other than document.write? Because I don't want to delete the html that I would make later.
All I wanted is to post js array values into html table.
when I write: document.getElementById("demo").innerHTML += '<table><tr><td>'+item +'</td></tr></table>';
it works but creates table everytime which is wrong
<html>
<head>
<style>
table, td {
border: 1px solid black;
}
</style>
</head>
<body>
<span id="demo"></span>
<script>
document.write("<table>");
arrayjs.forEach(myFunction);
document.write("</table>");
function myFunction(item) {
document.getElementById("demo").innerHTML += '<tr><td>'+item +'</td></tr>';
}
</script>
</body>
</html>