Untitled
unknown
typescript
4 years ago
387 B
8
Indexable
const data = {
John: [70, 60, 80],
Peter: [20, 30, 60],
Jacob: [90, 90, 90],
};
function getGrading(data: Object) {
const grading = {};
for (const item in data) {
const avg = data[item].reduce((a, b) => a + b) / data[item].length;
grading[item] = [avg, avg > 60 ? 'Passed' : 'Failed'];
}
return grading;
}
const grading = getGrading(data);
console.log(grading);
Editor is loading...