这个作业属于哪个课程 | https://edu.cnblogs.com/campus/sdscfz/SF3/ |
---|---|
这个作业要求在哪里 | https://edu.cnblogs.com/campus/sdscfz/SF3/homework/12953 |
这个作业的目标 | 第七次作业-数组输出最大值 |
<!DOCTYPE html>````
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="./chon.js"></script>
</body>
</html>
JS
var numbers=[];
for (var i = 1; i <= 5; i++) {
var num = prompt("请输入第" + i + "个数字");
numbers.push(Number(num));
}
var maxNum = Math.max.apply(null, numbers);
document.write("最大值为:" + maxNum);