你好我想讓用戶輸入幾個標記,並在最後給出最高分和最低分,但由於某種原因它打印兩次,並在第二次打印無限和想法?JavaScript打印多次
var gradeAwarded;
var gradeAwarded;
var repeate = true;
var max;
var A;
var B;
var C;
var F;
var repeat, studentArr = [], markArr = [];
while (repeat !== 'n' && repeat !== 'N'){
studentArr.push(prompt("Enter Student Name: "));
markArr.push(parseInt (prompt("Enter Student mark: ")));
repeat = prompt ("Do you want to enter another student: y/n");
}
Array.prototype.max = function() {
return Math.max.apply(Math, markArr);
};
Array.prototype.min = function() {
return Math.min.apply(Math, markArr);
};
var min = markArr.min();
var max = markArr.max();
if (markArr <0 || markArr >100){
alert("Grate out of bounds");
}else if (markArr >= 83){
gradeAwarded = "A";
A = +1;
}else if (markArr >= 70){
gradeAwarded = "B";
B = +1;
}else if (markArr >= 50){
gradeAwarded = "C";
C = +1;
}else if (markArr >= 0){
gradeAwarded = "F";
F = +1;
}
document.write("The Highest mark was : "+max);
document.write("The Lowest mark was : "+min);
你是對的它應該是||但對於一些振振有辭它使一個infenite循環 – HelloWorld
你好,我想顯示像我的數據,以便 學生馬克級 學生馬克級 學生馬克級 學生馬克級 學生馬克 級 如何將我去這這是我的代碼不必介意底部的document.write作爲我作業的另一部分。 – HelloWorld
你問題不清楚。請打開一個網絡問題並進行解釋 –