Project · JavaScript Programming (language in depth)
Project: class results and report cards
The brief
The class teacher of 10-B spends a whole weekend on results in a spreadsheet. Write the program instead: totals and percentages, grades, pass and compartment rules, a rank list with shared ranks for ties, the topper of each subject, and a neatly printed report card for each student.
Why it matters
Schools, coaching institutes and colleges across India produce results every term, and the rules always need care: rounding, ties, edge cases like 33 exactly. This project uses everything from the beginner level (numbers, strings, decisions, loops, functions, arrays and objects) on a task every teacher understands.
Skills you practise
- Object.values and Object.keys
- reduce and filter
- a lookup table for grades
- rules with if
- sorting with two keys
- ranks with ties
- Math.max with spread
- padEnd and padStart for neat text
What you will have at the end
results.js: a tested results program that prints the rank list, toppers and a report card for every student.
How it is marked (rubric, 100 points)
| Correct resultsEvery check passes, including ties, boundaries and the empty class. | 45 |
|---|---|
| Good structureSmall functions that reuse each other; rules in tables and named constants. | 25 |
| No side effectsThe class list is never reordered or changed. | 15 |
| Readable outputThe report card lines up and reads well when printed. | 15 |
0/6 steps done
Step 1 of 6
Totals and percentages
total(marks) adds up a marks object like { English: 92, Maths: 95, … }, and percentage(marks) returns the average rounded to 1 decimal place (0 when there are no subjects).
The marks are an object, not an array, so Object.values(marks) gives the list of numbers to add with reduce. Each subject is out of 100, so the percentage is simply the average. Round to 1 decimal with the × 10 / 10 trick. Guard against an empty object: dividing by 0 gives NaN, which would spread through every later calculation.
Run shows what your code prints. Check runs the step's tests. Ctrl+Enter checks too.