BACK
PracticeReal-life: zipWith() chart coordinates
PRACTICE · 77 · 練

Real-life: zipWith() chart coordinates

Pair up the x/y axes into the points x:10 and y:20.

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

const labels$ = of('x', 'y');
const values$ = of(10, 20);

const result$ = labels$.pipe(
  zipWith(values$),
  map(([label, value]) => label + ':' + value)
);

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