The Grade Counter
JavaScript
20 pts
The Grade Counter
Write a function countGrades(list) that returns a new object counting how often each grade appears, like { A: 3, B: 2, C: 1 }. Use bracket notation with the loop variable. It must work for any list (an empty list gives {}).
Store the result for grades in result, then print the object, the number of A grades, and whether a D grade exists (use in). Expected output:
{ A: 3, B: 2, C: 1 }
A: 3
Any D? false
Checklist
- Write
countGrades(list)that returns a new counting object. - Check for a D grade with
in. - Print the object, the A count and the D check.
🔑 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.
