20-forEach循环语句
//forEach循环
//array.forEach(function(currentValue,index,array){})
//currentValue当前元素 index 索引 array原数组
//forEach循环
var str = "<ul>";
arr.forEach(function(item,index,array){
str+="<li>"+item+"</li>" //item == arr[i]
//console.log(array);
})
str += "</ul>";
//计算数据的合
var arr2 = [1,2,3,4,5,6,7];
var n = 0;
arr2.forEach(function(item){
n+=item;
});
document.querySelector("div").innerHTML = n;