JS Built-ins
← Math160 / 215
Mathmaxintermediate

Math.max() β€” With NaN

πŸ“– Usage Example
// Largest of the given numbers
Math.max(1, 5, 3)   // β†’ 5
Math.max(-1, -5)    // β†’ -1

Use Math.max() to find the largest value among a set of numbers, or to clamp a minimum bound.

Math.max()

Returns the largest of the given numbers.

Challenge: Observe that Math.max(1, NaN) returns NaN.

πŸ’‘ Hints (1)
  • β€’ Any comparison involving NaN produces NaN