0
0
MongoDBquery~10 mins

$lt and $lte for less than in MongoDB - Interactive Code Practice

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

Complete the code to find documents where the age is less than 30.

MongoDB
db.users.find({ age: { [1]: 30 } })
Drag options to blanks, or click blank then click option'
A$gte
B$gt
C$lt
D$eq
Attempts:
3 left
💡 Hint
Common Mistakes
Using $gt instead of $lt will find documents with age greater than 30.
Using $eq will find documents with age exactly 30, not less than 30.
2fill in blank
medium

Complete the code to find documents where the score is less than or equal to 85.

MongoDB
db.scores.find({ score: { [1]: 85 } })
Drag options to blanks, or click blank then click option'
A$gt
B$lte
C$lt
D$ne
Attempts:
3 left
💡 Hint
Common Mistakes
Using $lt will exclude documents where score equals 85.
Using $gt or $ne will not find documents with score less than or equal to 85.
3fill in blank
hard

Fix the error in the query to find documents where price is less than 100.

MongoDB
db.products.find({ price: { [1]: 100 } })
Drag options to blanks, or click blank then click option'
A$lt
B$lt:
C$lte
D$gt
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the colon after the operator causes syntax errors.
Using $gt instead of $lt changes the query logic.
4fill in blank
hard

Fill both blanks to find documents where quantity is less than 50 and price is less than or equal to 20.

MongoDB
db.inventory.find({ quantity: { [1]: 50 }, price: { [2]: 20 } })
Drag options to blanks, or click blank then click option'
A$lt
B$gt
C$lte
D$eq
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up $gt and $lt changes the query logic.
Using $eq will only match exact values, not ranges.
5fill in blank
hard

Fill all three blanks to find documents where age is less than 40, score is less than or equal to 90, and height is less than 180.

MongoDB
db.people.find({ age: { [1]: 40 }, score: { [2]: 90 }, height: { [3]: 180 } })
Drag options to blanks, or click blank then click option'
A$lt
B$lte
C$gt
D$eq
Attempts:
3 left
💡 Hint
Common Mistakes
Using $gt instead of $lt or $lte reverses the condition.
Using $eq only matches exact values, not ranges.