0
0
Firebasecloud~10 mins

Nested objects and arrays in Firebase - Interactive Code Practice

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

Complete the code to add a nested object to Firestore.

Firebase
db.collection('users').doc('user1').set({ profile: [1] })
Drag options to blanks, or click blank then click option'
Anull
B['Alice', 30]
C'Alice'
D{ name: 'Alice', age: 30 }
Attempts:
3 left
💡 Hint
Common Mistakes
Using an array instead of an object.
Using a string instead of an object.
2fill in blank
medium

Complete the code to add an array of strings inside a Firestore document.

Firebase
db.collection('tasks').doc('task1').set({ tags: [1] })
Drag options to blanks, or click blank then click option'
A['urgent', 'home']
Burgent, home
C'urgent, home'
D{ 'urgent', 'home' }
Attempts:
3 left
💡 Hint
Common Mistakes
Using curly braces {} which create objects, not arrays.
Using a string instead of an array.
3fill in blank
hard

Fix the error in the nested object assignment to Firestore.

Firebase
db.collection('orders').doc('order1').set({ details: [1] })
Drag options to blanks, or click blank then click option'
A{ item: 'book', qty: 2 }
Bitem: 'book', qty: 2
C'{ item: book, qty: 2 }'
D[{ item: 'book', qty: 2 }]
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of an object.
Using an array when an object is expected.
4fill in blank
hard

Fill both blanks to create a nested object with an array inside Firestore.

Firebase
db.collection('projects').doc('proj1').set({ info: [1], tags: [2] })
Drag options to blanks, or click blank then click option'
A{ name: 'Build Shed', status: 'open' }
B['open', 'urgent']
C{ name: 'Build Shed', status: 'closed' }
D['done', 'low']
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping object and array types.
Using strings instead of arrays or objects.
5fill in blank
hard

Fill all three blanks to create a Firestore document with nested objects and arrays.

Firebase
db.collection('events').doc('event1').set({ organizer: [1], attendees: [2], details: [3] })
Drag options to blanks, or click blank then click option'
A{ name: 'John Doe', contact: 'john@example.com' }
B['Alice', 'Bob', 'Charlie']
C{ date: '2024-07-01', location: 'Park' }
D['2024-07-01', 'Park']
Attempts:
3 left
💡 Hint
Common Mistakes
Using arrays where objects are needed.
Using strings instead of arrays or objects.