var ave;
for(var i=0i<array.lenghti++){
ave+=array[i]
}
ave/=i
return ave
}
alert(getAve([1,2,3,4,5]))
取得数组中的平均值
<script>var arr=[1,2,3,4,5,6]
var sum=0
for (var i = 0 i < arr.length i++) {
sum+=parseInt(arr[i])
}
var avg=Math.ceil(sum/arr.length)
alert(avg)
</script>