0
0
Firebasecloud~10 mins

Ordering results 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 order documents by the field 'score' in ascending order.

Firebase
db.collection('games').orderBy('[1]').get()
Drag options to blanks, or click blank then click option'
Aname
Bdate
Cscore
Dlevel
Attempts:
3 left
💡 Hint
Common Mistakes
Using a field name that does not exist in the documents.
Forgetting to call orderBy before get().
2fill in blank
medium

Complete the code to order documents by 'date' in descending order.

Firebase
db.collection('games').orderBy('date', '[1]').get()
Drag options to blanks, or click blank then click option'
Adesc
Bascending
Cdescending
Dasc
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ascending' or 'descending' instead of 'asc' or 'desc'.
Omitting the direction argument defaults to ascending.
3fill in blank
hard

Fix the error in the code to order by 'level' ascending.

Firebase
db.collection('games').orderBy([1]).get()
Drag options to blanks, or click blank then click option'
A'level', 'asc'
B'level', 'desc'
Clevel
D'level'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing multiple arguments inside one parameter.
Not using quotes around the field name.
4fill in blank
hard

Fill both blanks to order by 'score' descending and then by 'date' ascending.

Firebase
db.collection('games').orderBy('[1]', '[2]').orderBy('date', 'asc').get()
Drag options to blanks, or click blank then click option'
Ascore
Bdesc
Casc
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of fields.
Using wrong direction strings.
5fill in blank
hard

Fill all three blanks to order by 'level' descending, then by 'score' ascending, and finally by 'date' ascending.

Firebase
db.collection('games').orderBy('[1]', '[2]').orderBy('[3]', 'asc').orderBy('date', 'asc').get()
Drag options to blanks, or click blank then click option'
Alevel
Bdesc
Cscore
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up field names and directions.
Using wrong direction strings.
Not chaining orderBy calls correctly.