我想知道如何將此數組插入表中。這是我的代碼;我想它顯示是這樣的:JavaScript如何將數組插入表中
學生姓名學生馬克學生成績
如果有誰知道怎麼樣,這將不勝感激。
var gradeAwarded;
var max;
var A =0;
var B =0;
var C=0;
var F=0;
var Sum = 0
var average
var repeat, studentArr = [], markArr = [];
while (repeat !== 'n'){
studentArr.push(prompt("Enter Student Name: ", "Ross"));
markArr.push(parseInt (prompt("Enter Student mark: ", 50)));
if (markArr <0 || markArr >100){
alert("Grate out of bounds");
}else if (markArr >= 83){
gradeAwarded = "A";
A = A + 1;
}else if (markArr >= 70){
gradeAwarded = "B";
B = B+1;
}else if (markArr >= 50){
gradeAwarded = "C";
C = C+1;
}else if (markArr >= 0){
gradeAwarded = "F";
F = F+1;
}
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);
};
for(var x = 0; x < markArr.length; x ++)
{
Sum = Sum + markArr[x];
}
average = Sum/markArr.length;
var min = markArr.min();
var max = markArr.max();
for(var i = 0; i < markArr.length; i++)
document.write(<tr> markArr[i] </tr>);
document.write("The Highest mark was : "+max+"<br>");
document.write("The Lowest mark was : "+min +"<br>");
document.write("The Average mark was : "+average+"<br>");
document.write("number A grades : "+A+"<br>");
document.write("number B grades : "+B+"<br>");
document.write("number C grades : "+C+"<br>");
document.write("number F grades : "+F+"<br>");