A simple JavaScript project that fulfills the user stories from the FreeCodeCamp JavaScript Algorithms and Data Structures certification lab. This app calculates class averages, assigns letter grades, checks for passing status, and returns formatted student messages.
The app implements the following user stories:
-
β
getAverage(scores)
β Returns the average score from an array of test scores. -
β
getGrade(score)
β Returns the corresponding letter grade:100
β"A+"
90β99
β"A"
80β89
β"B"
70β79
β"C"
60β69
β"D"
0β59
β"F"
-
β
hasPassingGrade(score)
β Returnstrue
if the score is passing (anything except"F"
),false
otherwise. -
β
studentMsg(totalScores, studentScore)
β Returns a message like:"Class average: 85.4. Your grade: B. You passed the course."
or"Class average: 52.6. Your grade: F. You failed the course."
To use the functions, simply import or run the JavaScript code in your browser or a Node.js environment:
console.log(studentMsg([90, 80, 70, 60, 100], 85));
// Output: Class average: 80.0. Your grade: B. You passed the course.
- JavaScript (ES6+)
- Basic algorithm and control flow
- Functional programming approach
gradebook-app/
βββ README.md
βββ index.js
This project helps reinforce the following JavaScript concepts:
- Writing pure functions
- Conditional logic
- Array iteration (
for...of
) - String interpolation
- Clean, readable code
- Clone the repository or copy the script into your JS environment (e.g., CodePen, JSFiddle, VSCode).
- Paste the code and run in browser console or terminal (Node.js).
- Use the
studentMsg()
function with sample data to see results.
studentMsg([56, 23, 89, 42, 75, 11, 68, 34, 91, 19], 100);
// Output: Class average: 50.8. Your grade: A+. You passed the course.
This solution was built as part of the FreeCodeCamp JavaScript Algorithms and Data Structures Certification. Check out the full curriculum here: https://www.freecodecamp.org/learn
Tendai Gumunyu π« @costa_developer on Instagram