Untitled
unknown
typescript
3 years ago
387 B
5
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...