Skip to main content

$max

The $max operator returns the larger of two values. If the values are of numeric type, it compares them numerically. If they are strings, it performs lexicographic comparison.

Input

  • An array containing exactly two values to compare

Output

  • The larger of the two input values

Examples

Numeric Comparison

Result: 10

String Comparison

Result: "banana"

Field Value Comparison

Result: The higher score between score1 and score2