Capstone project

Project: a course recommendation engine

Lesson 20 of 20 · 24 min · Module 6: Design, validate & debug

Build a small recommendation feature from imperfect records. Combine the skills into one function with a clear contract and predictable edge cases.

Start this lesson →

Free. No installation: you write and run the code in your browser, and it is checked automatically.

By the end, you’ll be able to…

  • Combine validation, transformation, and ordering
  • Prove correctness with edge-case tests

The idea

Break the work into validation, selection, ordering, and presentation. Keep records owned by the caller unchanged so other features can still use the original data.

// Plan before coding:
// 1. Keep valid, active courses within the time budget.
// 2. Sort by duration, then title.
// 3. Return only cleaned titles.

01Turn the brief into stages

Give every rule a place in the pipeline. A record must pass all eligibility rules before it can be recommended.

02Normalize before presentation

Trim each accepted title into a new record. Use that same normalized title for both tie-breaking and the returned output.

03Test more than the main example

Check no records, exact budget boundaries, invalid data, tied durations, and unchanged inputs. These cases explain what the feature promises.

Your project brief

Write recommendCourses(records, maxMinutes). Include only non-array objects with active exactly true, a nonempty string title, and a finite positive numeric minutes value no greater than maxMinutes. Return trimmed titles sorted by minutes ascending, then trimmed title ascending using ASCII order. Preserve the input. maxMinutes is a nonnegative finite number.

What the checks look for

  • Selects active courses and sorts by duration
  • Cleans titles before applying a tie rule
  • Rejects broken shapes and invalid durations
  • Handles an empty list and a zero budget
  • Preserves caller-owned values and ordering
Try it in the editor →

Take this with you

A reliable feature is a set of explicit rules supported by tests.

Go a little further

Add an optional limit on the number of recommendations and test zero, one, and larger limits.

Learn JavaScript Foundations for free

20 short lessons with real code and instant checks.

See the whole course →