0
0
Firebasecloud~20 mins

Comparison operators (==, <, >, >=, <=) in Firebase - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Master of Firebase Comparison Operators
Get all challenges correct to earn this badge!
Test your skills under time pressure!
service_behavior
intermediate
2:00remaining
Firebase Realtime Database: Query with < operator
You want to retrieve all users whose age is less than 30 from your Firebase Realtime Database. Which query will correctly return these users?
Firebase
firebase.database().ref('users').orderByChild('age').<operator>(30).once('value').then(snapshot => { /* handle data */ });
Afirebase.database().ref('users').orderByChild('age').endBefore(30).once('value')
Bfirebase.database().ref('users').orderByChild('age').startAt(30).once('value')
Cfirebase.database().ref('users').orderByChild('age').equalTo(30).once('value')
Dfirebase.database().ref('users').orderByChild('age').endAt(29).once('value')
Attempts:
2 left
💡 Hint
Think about which method limits results to values less than a given number.
Architecture
intermediate
2:00remaining
Firestore: Filtering documents with >= operator
You want to get all orders with a total amount greater than or equal to 100 in Firestore. Which query correctly achieves this?
Firebase
firebase.firestore().collection('orders').where('total', '<operator>', 100).get().then(snapshot => { /* handle data */ });
Afirebase.firestore().collection('orders').where('total', '>=', 100).get()
Bfirebase.firestore().collection('orders').where('total', '>', 100).get()
Cfirebase.firestore().collection('orders').where('total', '<=', 100).get()
Dfirebase.firestore().collection('orders').where('total', '==', 100).get()
Attempts:
2 left
💡 Hint
Remember that >= means greater than or equal to.
security
advanced
2:00remaining
Firestore Security Rules: Using == operator
You want to allow users to read their own profile document only if their user ID matches the document ID. Which security rule condition correctly enforces this?
Firebase
match /users/{userId} { allow read: if <condition>; }
Arequest.auth.uid == userId
Brequest.auth.uid < userId
Crequest.auth.uid != userId
Drequest.auth.uid >= userId
Attempts:
2 left
💡 Hint
Check for exact equality between authenticated user ID and document ID.
Best Practice
advanced
2:00remaining
Choosing correct comparison operator in Firestore queries
You want to query Firestore for products priced less than or equal to $50. Which operator should you use in the where clause to get all products priced at $50 or less?
Firebase
firebase.firestore().collection('products').where('price', '<operator>', 50).get()
A'<'
B'<='
C'>'
D'=='
Attempts:
2 left
💡 Hint
Think about including the price 50 in the results.
🧠 Conceptual
expert
3:00remaining
Understanding Firebase Realtime Database query behavior with >= and == operators
Consider this Firebase Realtime Database query to find users with age greater than or equal to 21: firebase.database().ref('users').orderByChild('age').startAt(21).once('value') What will be the difference in results if you replace startAt(21) with equalTo(21)?
ABoth return users aged 21 and older
BstartAt(21) returns only users aged exactly 21; equalTo(21) returns users aged 21 and older
CstartAt(21) returns users aged 21 and older; equalTo(21) returns only users aged exactly 21
DBoth return only users aged exactly 21
Attempts:
2 left
💡 Hint
Consider how startAt and equalTo filter data differently.