Having Problems solving Data Structures: Objects "averages exercise"

var getAverages = function(students){
var averages = [];
let sum=0;
//write your code here
for (grades in students) {
for (i=0;students[grades].length;i++) {
let avg = sum/grades.length;

return averages;

this is my code and it doesnt work! what changes should i make?

link to the problem:

Hi! The input variable students is an array, where each element is an Object. You’ve used the loop on students, which will return the index of each element, i.e. 0,1,2,... rather than access the grades property of every student.

In the next loop, your condition students[grades].length is incorrect as you missed any comparison operators.

The line sum += i is incorrect since it will add the indexes of each grade rather than the actual grade value.

Finally, the average must be calculated after the inner loop finishes running.

You can also look at the solution provided in the challenge for more help!