Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to find all documents in the collection.
MongoDB
db.collection.find([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an empty array instead of an empty object.
Using null which does not work as a query filter.
✗ Incorrect
Using an empty object {} as the query returns all documents in the collection.
2fill in blank
mediumComplete the code to find documents where age is 25.
MongoDB
db.collection.find({ age: [1] }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around 25, which makes it a string.
Using a query operator without the correct syntax.
✗ Incorrect
Use the number 25 without quotes to match the age field exactly.
3fill in blank
hardFix the error in the query to find documents with name 'Alice'.
MongoDB
db.collection.find({ name: [1] }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around string values.
Using single quotes which may cause errors in some environments.
✗ Incorrect
String values in MongoDB queries must be in double quotes.
4fill in blank
hardFill both blanks to find documents where age is greater than 30.
MongoDB
db.collection.find({ age: { [1]: [2] } }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $lt instead of $gt.
Using a wrong number value.
✗ Incorrect
The operator $gt means 'greater than', so { age: { $gt: 30 } } finds ages over 30.
5fill in blank
hardFill all three blanks to find documents where name starts with 'J' and age is less than 40.
MongoDB
db.collection.find({ name: { [1]: [2] }, age: { [3]: 40 } }) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using $gt instead of $lt for age.
Not using regex correctly for name.
✗ Incorrect
Use $regex with "^J" to match names starting with 'J', and $lt to find ages less than 40.