0
0
MongoDBquery~5 mins

String expressions ($concat, $toUpper, $toLower) in MongoDB - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the $concat expression do in MongoDB?
It joins two or more strings together into one string.
Click to reveal answer
beginner
How does $toUpper transform a string in MongoDB?
It changes all letters in the string to uppercase letters.
Click to reveal answer
beginner
What is the purpose of $toLower in MongoDB string expressions?
It converts all letters in a string to lowercase letters.
Click to reveal answer
intermediate
Write a MongoDB expression to combine first name and last name with a space in between.
Use { $concat: ["$firstName", " ", "$lastName"] } to join firstName and lastName with a space.
Click to reveal answer
intermediate
How can you convert a user's name to uppercase and then concatenate with a greeting in MongoDB?
Use { $concat: ["Hello, ", { $toUpper: "$name" }] } to greet with uppercase name.
Click to reveal answer
Which MongoDB expression joins multiple strings into one?
A$toUpper
B$toLower
C$concat
D$split
What does $toUpper do to the string "hello"?
A"HELLO"
B"hello"
C"Hello"
D"hElLo"
How would you convert "WORLD" to lowercase in MongoDB?
A{ $toLower: "WORLD" }
B{ $toUpper: "WORLD" }
C{ $concat: ["W", "O", "R", "L", "D"] }
D{ $substr: ["WORLD", 0, 5] }
Which expression correctly joins firstName and lastName with a space?
A{ $concat: ["$firstName", "$lastName"] }
B{ $concat: ["$firstName", " ", "$lastName"] }
C{ $toUpper: ["$firstName", " ", "$lastName"] }
D{ $toLower: ["$firstName", " ", "$lastName"] }
What will this expression return? { $concat: ["Hi, ", { $toUpper: "$user" }] } if user is "anna"?
A"Hi, anna"
B"hi, ANNA"
C"ANNA"
D"Hi, ANNA"
Explain how to use $concat, $toUpper, and $toLower in MongoDB to format a full name.
Think about joining first and last names and changing case.
You got /4 concepts.
    Describe a real-life example where $concat and $toUpper could be used together in a MongoDB query.
    Imagine saying hello to a user with their name in capital letters.
    You got /3 concepts.