<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
function pjs(arr){
let he = 0
for(num of arr){
he += num
}
let pjz = he / arr.length
return pjz
}
let array = [1,2,3,4,5,6,7,8,9,10]
let result = pjs(array)
console.log(result)
</script>
</body>
</html>
2.编写一个函数,形参是一个数组,返回数组中的最大值。
!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
let arr = [5,3,6,8,9,10,20]
function.getMax(arr){
let max = arr[0]
for(let i =1;i < arr.length;i++)
if (max < arr[i]){
max = arr[i]
}
}
return max
console.log(getMax(array))
</script>
</body>
</html>