I need to get the highest score from this Array, but it kept giving me the [0] position and the highest which is 88 and 98
const classInfo = {
students: [
{ firstName: "Joe", lastName: "Smith", score: 88 },
{ firstName: "John", lastName: "Doe", score: 65 },
{ firstName: "Joel", lastName: "Garcia", score: 98 },
{ firstName: "Judy", lastName: "Johnson", score: 77 },
{ firstName: "Anne", lastName: "Dew", score: 88 },
]
};
let best_result //edited
for (let i = 0; i < classInfo.students.length; i++) {
if (classInfo.students[i].score > best_result) {
best_result = classInfo.students[i].score;
console.log(best_result);
}