<script>
// 求任意数组中的最大值,并返回
function getMax(arr) {
// 让变量max 等于 arr[0]
let max = arr[0];
// 遍历数组
for(let i = 0; i < arr.length -1; i++){
// max 等于数组里最大的数值
if(max < arr[i]){
max = arr[i];
}
}
// 把max 写到页面上
return document.write(max)
}
getMax([1,5,20,100,50,35])
</script>