How to call a function several times with the arguments in JavaScript [duplicate]
Solution 1:
Change your for
loop:
for (i = 0; i <= (n-1); i++) {
var list = names[i];
var myList = document.getElementById("list");
myList.innerHTML += "<li class='list-group-item' id='listItem'>"+ list + "</li>" + "<br />";
}
Use +=
instead of =
. Other than that, your code looks fine.