Each time addTask runs, it calls all tasks in the array, not just the new one.
Step 2: Understand effect on task execution
This causes all tasks to run repeatedly, not one by one as intended.
Final Answer:
All tasks run every time a new task is added -> Option B
Quick Check:
forEach runs all tasks on each add [OK]
Hint: Check where tasks.forEach is called inside addTask [OK]
Common Mistakes:
Thinking tasks never run
Assuming tasks run only once
Believing tasks run in reverse
5. You want to scale a Firebase app with many users writing data simultaneously. Which advanced pattern best helps avoid database write conflicts?
hard
A. Use sharding to split data into multiple parts
B. Use caching to store data locally only
C. Use a single large document for all writes
D. Use queueing to process writes one at a time
Solution
Step 1: Identify write conflict problem
Many users writing at once can cause conflicts if writes happen simultaneously on the same data.
Step 2: Match pattern to problem
Queueing processes writes one by one, preventing conflicts. Sharding splits data but may not prevent conflicts on same shard. Caching stores data locally but doesn't solve write conflicts. A single large document increases conflict risk.
Final Answer:
Use queueing to process writes one at a time -> Option D
Quick Check:
Queueing controls write order to avoid conflicts [OK]
Hint: Queue writes to avoid conflicts in simultaneous access [OK]
Common Mistakes:
Thinking sharding alone prevents conflicts
Using caching to solve write conflicts
Storing all writes in one document
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.