Encountering an issue with calculating the total grades in the class, as I am receiving an 'NAN' error. Attempted to use parseInt() and .value on students[i].grade but still facing difficulties because of my inexperience.
var students= [{name:"David", grade:80},
{name:"Vinoth", grade:77},
{name:"Divya", grade:88},
{name:"Ishitha", grade:95},
{name:"Thomas", grade:68}];
var average;
for(i = 0; i < students.length; i++){
console.log(students[i].grade);
average += Number(students[i].grade.value);
console.log(average);
}
The output from console log appears as follows:
80 NaN 77 NaN 88 NaN 95 NaN 68 NaN