springboot怎么把数据传给前端:springboot 如何引入前端 bootstrap?
这种问题网上一搜一大堆,你可以具体找一篇文章试试,遇到问题可以针对相关问题去提问。springboot通过jar包方式引入bootstrap_个人文章 - SegmentFault 思否 这不是查查就
顺晟科技
2022-10-19 14:17:56
227
目前我的jsfiddle允许用户一次输入一些考试成绩,一个数字,并显示这些数字的平均分和总分。当前,如果他们在框中输入-999,这意味着他们已经完成了数字输入,可以计算平均值和总数。
如何编辑它,以便当用户第一次输入-999时,显示“未输入分数”?
<script>
function userInput() {
var examScores = 0;
var totScores = 0;
var i = 0;
var scores = [];
while (true) {
examScores = parseInt(prompt("Enter a score or enter -999 when you're finished: "));
if (examScores === -999 && scores.length === 0) {
document.getElementById("scores").innerHTML = "No score entered.";
break;
}
else if (examScores === -999) {
break;
}
else {
scores.push(examScores);
i++;
}
}
for(var i = 0; i < scores.length; i++) {
totScores = totScores + scores[i];
}
document.getElementById("scores").innerHTML = "<h1> The sum of these scores is: "+totScores.toFixed(2)+"<br/> The average of these scores is: "+(totScores/scores.length).toFixed(2);
}
</script>
<h1>Exam Scores</h1>
<h3>Click to enter scores</h3>
<input type="button" value="Enter student scores" onclick="userInput()" />
<div id="scores"></div>
顺晟科技:
您需要返回而不是中断循环。
<script>
function userInput() {
var examScores = 0;
var totScores = 0;
var i = 0;
var scores = [];
while (true) {
examScores = parseInt(prompt("Enter a score or enter -999 when you're finished: "));
if (examScores === -999 && scores.length === 0) {
document.getElementById("scores").innerHTML = "No score entered.";
break;
}
else if (examScores === -999) {
break;
}
else {
scores.push(examScores);
i++;
}
}
for(var i = 0; i < scores.length; i++) {
totScores = totScores + scores[i];
}
document.getElementById("scores").innerHTML = "<h1> The sum of these scores is: "+totScores.toFixed(2)+"<br/> The average of these scores is: "+(totScores/scores.length).toFixed(2);
}
</script>
<h1>Exam Scores</h1>
<h3>Click to enter scores</h3>
<input type="button" value="Enter student scores" onclick="userInput()" />
<div id="scores"></div>
单独打破循环将导致函数继续执行,因此总是到达
<script>
function userInput() {
var examScores = 0;
var totScores = 0;
var i = 0;
var scores = [];
while (true) {
examScores = parseInt(prompt("Enter a score or enter -999 when you're finished: "));
if (examScores === -999 && scores.length === 0) {
document.getElementById("scores").innerHTML = "No score entered.";
break;
}
else if (examScores === -999) {
break;
}
else {
scores.push(examScores);
i++;
}
}
for(var i = 0; i < scores.length; i++) {
totScores = totScores + scores[i];
}
document.getElementById("scores").innerHTML = "<h1> The sum of these scores is: "+totScores.toFixed(2)+"<br/> The average of these scores is: "+(totScores/scores.length).toFixed(2);
}
</script>
<h1>Exam Scores</h1>
<h3>Click to enter scores</h3>
<input type="button" value="Enter student scores" onclick="userInput()" />
<div id="scores"></div>
由于上面的行正在执行,您自己的工作将被覆盖。从循环内返回将结束函数的执行。
05
2022-12
02
2022-12
02
2022-12
29
2022-11
29
2022-11
24
2022-11