I need help with inserting an array into a table format. My code snippet should display the data in this structure:
Student Name Student Mark Student Grade
If anyone has insight on how to achieve this, I would really appreciate it.
let gradeAwarded;
let maxVal;
let A =0;
let B =0;
let C=0;
let F=0;
let sum = 0
let average
let 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("Grade 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.maxValue = function() {
return Math.max.apply(Math, markArr);
};
Array.prototype.minValue = function() {
return Math.min.apply(Math, markArr);
};
for(let x = 0; x < markArr.length; x ++)
{
sum = sum + markArr[x];
}
average = sum / markArr.length;
let minValue = markArr.minValue();
let maxValue = markArr.maxValue();
for(let i = 0; i < markArr.length; i++)
document.write(<tr> markArr[i] </tr>);
document.write("The Highest mark was : "+maxValue+"<br>");
document.write("The Lowest mark was : "+minValue +"<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>");