0
0
Firebasecloud~10 mins

Increment operations 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 increment a Firestore field by 1.

Firebase
const increment = firebase.firestore.FieldValue.[1](1);
Drag options to blanks, or click blank then click option'
AincrementField
Bincrement
CincrementValue
DincrementBy
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-existent method like 'incrementBy' or 'incrementValue'.
Trying to increment without using FieldValue.
2fill in blank
medium

Complete the code to update the 'likes' field by incrementing it by 5.

Firebase
docRef.update({ likes: firebase.firestore.FieldValue.[1](5) });
Drag options to blanks, or click blank then click option'
Aincrement
Badd
Cincrease
Dplus
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'add' which is not a valid method here.
Using 'increase' or 'plus' which do not exist in Firestore API.
3fill in blank
hard

Fix the error in the code to correctly increment the 'score' field by 10.

Firebase
db.collection('games').doc('game1').update({ score: firebase.firestore.FieldValue.[1](10) });
Drag options to blanks, or click blank then click option'
Aupdate
Badd
Cincrement
Dincrease
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'add' or 'increase' which are not valid Firestore methods.
Using 'update' as a method of FieldValue which is incorrect.
4fill in blank
hard

Fill both blanks to increment 'views' by 1 and 'shares' by 2 in a Firestore document update.

Firebase
docRef.update({ views: firebase.firestore.FieldValue.[1](1), shares: firebase.firestore.FieldValue.[2](2) });
Drag options to blanks, or click blank then click option'
Aincrement
Badd
Cincrease
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using different methods like 'add' or 'increase' which are invalid.
Using 'update' which is not a FieldValue method.
5fill in blank
hard

Fill all three blanks to increment 'likes' by 3, 'comments' by 4, and 'shares' by 5 in a Firestore update.

Firebase
docRef.update({ likes: firebase.firestore.FieldValue.[1](3), comments: firebase.firestore.FieldValue.[2](4), shares: firebase.firestore.FieldValue.[3](5) });
Drag options to blanks, or click blank then click option'
Aincrement
Badd
Cincrease
Dupdate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'add', 'increase', or 'update' which are not valid FieldValue methods.
Mixing different methods for different fields.