← Pure functions lesson
Lab

Pure functions

Sign in to run your code

Read the brief and the starter here. With a free account you can edit it, run the sample, step through it and check your work, and your progress is kept.

type Trial = { id: string; endsOn: number };


function selectDue(trials: Trial[], today: number, window: number): Trial[] {
  return trials.filter(trial => {
    const daysLeft = trial.endsOn - today;
    return daysLeft >= 0;
  });
}