JS Built-ins
← Math89 / 215
Mathceilbeginner

Math.ceil() Leaves Integers Unchanged

πŸ“– Usage Example
// Round up to the nearest integer
Math.ceil(4.2)   // β†’ 5
Math.ceil(-4.2)  // β†’ -4

Use Math.ceil() when you need to round a number up to the next whole integer.

Math.ceil(x)

When the input is already an integer, Math.ceil() returns it unchanged. Math.ceil(4) returns 4.

Challenge: Verify that Math.ceil() is idempotent for integers.

πŸ’‘ Hints (2)
  • β€’ An integer is already at its ceiling
  • β€’ ceil(n) = n for all integers n