Complete the code to use $cond to check if the field 'score' is greater than 50.
{ $cond: { if: { $gt: ["$score", [1]] }, then: "Pass", else: "Fail" } }The $cond expression checks if 'score' is greater than 50. If true, it returns "Pass", else "Fail".
Complete the $cond expression to return 'High' if 'age' is at least 18, otherwise 'Low'.
{ $cond: { if: { $gte: ["$age", [1]] }, then: "High", else: "Low" } }$gte means 'greater than or equal to'. We check if age is at least 18 to return 'High'.
Fix the error in the $switch expression to correctly return 'Child', 'Teen', or 'Adult' based on 'age'.
{ $switch: { branches: [ { case: { $lt: ["$age", [1]] }, then: "Child" }, { case: { $lt: ["$age", 20] }, then: "Teen" } ], default: "Adult" } }The first case should check if age is less than 18 to classify as 'Child'. Then less than 20 is 'Teen'. Otherwise, 'Adult'.
Fill both blanks to create a $cond expression that returns 'Adult' if age is 18 or more, else 'Minor'.
{ $cond: { if: { $[1]: ["$age", [2]] }, then: "Adult", else: "Minor" } }Use $gte to check if age is greater than or equal to 18 to return 'Adult'. Otherwise, return 'Minor'.
Fill all three blanks to create a $switch expression that returns 'Low', 'Medium', or 'High' based on 'score'.
{ $switch: { branches: [ { case: { $lt: ["$score", [1]] }, then: "Low" }, { case: { $lt: ["$score", [2]] }, then: "Medium" } ], default: [3] } }The first case checks if score is less than 50 for 'Low'. The second checks less than 80 for 'Medium'. Otherwise, 'High'.