Bird
0
0

You want to transform a stream of user objects to only their email addresses, but only if the user is active. Which operator chain correctly achieves this?

hard🚀 Application Q8 of 15
Angular - RxJS Operators
You want to transform a stream of user objects to only their email addresses, but only if the user is active. Which operator chain correctly achieves this?
Asource.pipe(map(u => u.email), filter(email => email.active))
Bsource.pipe(map(u => u.active), filter(active => active.email))
Csource.pipe(filter(u => u.active), map(u => u.email))
Dsource.pipe(filter(u => u.email), map(u => u.active))
Step-by-Step Solution
Solution:
  1. Step 1: Filter active users first

    Filter operator should check if user is active.
  2. Step 2: Map to extract email

    After filtering, map extracts the email property.
  3. Final Answer:

    source.pipe(filter(u => u.active), map(u => u.email)) -> Option C
  4. Quick Check:

    Filter active then map email = B [OK]
Quick Trick: Filter first, then map to transform data [OK]
Common Mistakes:
MISTAKES
  • Mapping before filtering
  • Filtering on wrong property
  • Swapping map and filter order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes