JS Built-ins
← Math158 / 215
Mathmaxintermediate

Math.max() β€” No Arguments

πŸ“– 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() with no arguments returns -Infinity.

πŸ’‘ Hints (1)
  • β€’ The identity element for max is -Infinity (every number is β‰₯ -Infinity)