BACK
PracticeReal-life: from() for a list of orders
PRACTICE · 02 · 練

Real-life: from() for a list of orders

Turn an array of order ids into a stream and add the prefix order-.

  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 { from, map } = Rx;

const ids = [101, 102, 103];

const result$ = from(ids).pipe(
  map(id => 'order-' + id)
);

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