javascript foreach append to string code example
Example: javascript add string inside foreach
var fruits = [1, 2, 3];
fruits.forEach(myFunction);
function myFunction(item, index) {
document.getElementById("demo").innerHTML += index + ":" + item + "<br>";
}