BACK
PracticeInterview: take() the first values
PRACTICE · 06 · 練

Interview: take() the first values

Take only the first 3 days from range(1, 10) and format them as day-N.

  1. Solve the task in the editor — no long theory.
  2. Run the check and compare your output with the expected result.
  3. Stuck? Open the solution and carry the approach into your own code.
Solution spoiler · click to reveal
const { range, take, map } = Rx;

const result$ = range(1, 10).pipe(
  take(3),
  map(day => 'day-' + day)
);

result$.subscribe(value => console.log(value));
script.ts // TypeScript
CONSOLE · Console output
Hit Run to see the result...