马上期末考试了,博主为大家预测一波考试成绩(多次取最大值喔[偷笑.jpg])。
源码奉上
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
margin: 300px auto;
display: flex;
justify-content: space-around;
height: 300px;
width: 500px;
border-left: 2px solid #000;
border-bottom: 2px solid #000;
align-items: flex-end;
}
.box div {
display: flex;
background-color: #e0e0e0;
flex-direction: column;
text-align: center;
justify-content: space-between;
}
.box div span {
margin-top: -20px;
width: 40px;
text-align: center;
}
.box div h4 {
margin-bottom: -20px;
width: 40px;
text-align: center;
}
</style>
</head>
<body>
<script>
let sub = null
let i = 1
document.write(
`<div class="box">`
)
while (sub = prompt(`请输入第${i++}个学科(输入空或者取消停止输入)`)) { //为sub更新值并作为循环的条件 若不输则为空 即false
let score = Math.floor(Math.random() * 40 + 61) //在60 - 100之间随机生成一个数字
document.write(`
<div style="height: ${score}px;">
<span>${score}</span>
<h4>${sub}</h4>
</div>
`)
}
document.write(
`</div>`
)
alert("准备好了么")
let arr = [3, 2, 1]
for (let k in arr) {
alert(arr[k])
}
</script>
</body>
</html>
祝大家期末关关难过关关过!!!!!!