Reputation: 13
I don’t know if this is similar or not to other topics. I’m basically testing my code at this point and I have no idea why it’s not working.
let p = document.querySelector("#demo");
let m = document.querySelector("body");
let msg = "";
let arr1 = [23, 55, 63, 88, 95];
for (i = 0; i < arr1.length; i++){
msg = arr1[i] + "<Br>";
}
p.innerHTML = msg;
Upvotes: 0
Views: 43
Reputation: 36311
We could just remove the loop all together and do a join:
let p = document.querySelector("#demo");
let arr1 = [23, 55, 63, 88, 95];
p.innerHTML = arr1.join('<br>');
<p id="demo"></p>
Upvotes: 1