0
0
Angularframework~10 mins

map operator for transformation in Angular - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the map operator from RxJS.

Angular
import { [1] } from 'rxjs/operators';
Drag options to blanks, or click blank then click option'
Amap
Btap
Cfilter
DswitchMap
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the wrong operator like filter or tap instead of map.
Forgetting to import from 'rxjs/operators'.
2fill in blank
medium

Complete the code to transform each emitted number by doubling it using map.

Angular
numbers$.pipe([1](x => x * 2)).subscribe(console.log);
Drag options to blanks, or click blank then click option'
Afilter
Bmap
Ctap
Dreduce
Attempts:
3 left
💡 Hint
Common Mistakes
Using filter instead of map, which filters values instead of transforming.
Using tap which only performs side effects without changing values.
3fill in blank
hard

Fix the error in the code to correctly transform emitted strings to uppercase using map.

Angular
source$.pipe([1](str => str.toUpperCase())).subscribe(console.log);
Drag options to blanks, or click blank then click option'
Afilter
BconcatMap
Ctap
Dmap
Attempts:
3 left
💡 Hint
Common Mistakes
Using filter which filters values instead of transforming.
Using tap which does not change the emitted values.
4fill in blank
hard

Fill both blanks to create a map operator that adds 10 to each emitted number and then filters out numbers less than 20.

Angular
source$.pipe([1](x => x + 10), [2](x => x >= 20)).subscribe(console.log);
Drag options to blanks, or click blank then click option'
Amap
Bfilter
Ctap
Dreduce
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of map and filter.
Using tap instead of filter for filtering.
5fill in blank
hard

Fill all three blanks to create a map operator that converts strings to lowercase, trims whitespace, and then filters out empty strings.

Angular
source$.pipe([1](str => str.toLowerCase()), [2](str => str.trim()), [3](str => str !== '')).subscribe(console.log);
Drag options to blanks, or click blank then click option'
Amap
Cfilter
Dtap
Attempts:
3 left
💡 Hint
Common Mistakes
Using tap instead of map for transformations.
Using map instead of filter to remove empty strings.