programming-examples/js/Conditional/Write a JavaScript program which compute, the average marks of the following students Then, this average is used to determine the corresponding grade..js

25 lines
780 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
var students = [['David', 80], ['Vinoth', 77], ['Divya', 88], ['Ishitha', 95], ['Thomas', 68]];
var Avgmarks = 0;
for (var i=0; i < students.length; i++) {
Avgmarks += students[i][1];
var avg = (Avgmarks/students.length);
}
alert("Average grade: " + (Avgmarks)/students.length);
if (avg < 60){
console.log("Grade : F");
}
else if (avg < 70) {
console.log("Grade : D");
}
else if (avg < 80)
{
console.log("Grade : C");
} else if (avg < 90) {
console.log("Grade : B");
} else if (avg < 100) {
console.log("Grade : A");
}