Bird
0
0

Find the mistake in this Angular RxJS code snippet:

medium📝 Debug Q6 of 15
Angular - RxJS Operators
Find the mistake in this Angular RxJS code snippet:
import { of } from 'rxjs';
import { map, filter } from 'rxjs/operators';

of(1, 2, 3).pipe(
  map(x => x * 3)
  filter(x => x > 4)
).subscribe(console.log);
Aof() cannot emit multiple values
BUsing map before filter is invalid
Csubscribe should be called before pipe
DMissing comma between operators inside pipe
Step-by-Step Solution
Solution:
  1. Step 1: Check pipe syntax

    Operators inside pipe must be separated by commas.
  2. Step 2: Identify error

    The code misses a comma between map and filter, causing a syntax error.
  3. Step 3: Validate other options

    Operator order is valid, subscribe is correctly called after pipe, and of can emit multiple values.
  4. Final Answer:

    Missing comma between operators inside pipe -> Option D
  5. Quick Check:

    Operators in pipe() must be comma-separated [OK]
Quick Trick: Separate operators with commas inside pipe() [OK]
Common Mistakes:
MISTAKES
  • Omitting commas between operators
  • Calling subscribe before pipe
  • Assuming operator order is always wrong

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes