The Report Card
JavaScript
20 pts
The Report Card
Write two functions for an object of marks:
formatMarks(obj)returns a string likeMaths: 90, Science: 85, English: 78. UseObject.entries,mapandjoin(", "). An empty object gives"".average(obj)returns the mean of all values. UseObject.valuesandreduce.
Print the formatted marks, the average with one decimal (toFixed(1)), and the object with JSON.stringify(marks, null, 2). Expected output:
Maths: 90, Science: 85, English: 78
Average: 84.3
{
"Maths": 90,
"Science": 85,
"English": 78
}
Checklist
- Write
formatMarks(obj)withObject.entries. - Write
average(obj)withObject.values. - Print the marks object as tidy JSON.
- Print all three outputs.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
