Bird
0
0

Given this code, what will be the output?

medium📝 Predict Output Q5 of 15
Angular - RxJS Operators
Given this code, what will be the output?
import { of } from 'rxjs';
import { map, filter } from 'rxjs/operators';

of(5, 10, 15).pipe(
  map(x => x + 1),
  filter(x => x < 12)
).subscribe(console.log);
A6, 10, 16
B6, 11
C5, 10
D6, 11, 16
Step-by-Step Solution
Solution:
  1. Step 1: Apply map operator

    Add 1 to each: 6, 11, 16.
  2. Step 2: Apply filter operator

    Keep values less than 12: 6 and 11.
  3. Final Answer:

    6, 11 -> Option B
  4. Quick Check:

    map then filter output = 6, 11 [OK]
Quick Trick: Order of operators affects output [OK]
Common Mistakes:
MISTAKES
  • Filtering before mapping
  • Including values >= 12
  • Not adding 1 before filtering

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes