Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an array instead of an object.
Using a string instead of an object.
✗ Incorrect
The nested object must be an object with keys and values, not an array or string.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using curly braces {} which create objects, not arrays.
Using a string instead of an array.
✗ Incorrect
Arrays in Firestore are represented as JavaScript arrays with square brackets [].
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of an object.
Using an array when an object is expected.
✗ Incorrect
The nested object must be an object literal, not a string or incomplete syntax.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping object and array types.
Using strings instead of arrays or objects.
✗ Incorrect
The 'info' field is an object, and 'tags' is an array of strings.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using arrays where objects are needed.
Using strings instead of arrays or objects.
✗ Incorrect
The 'organizer' and 'details' fields are objects, while 'attendees' is an array of strings.