JS Built-ins
GlobalFunctionsparseIntbeginner

parseInt β€” truncates decimal

πŸ“– Usage Example
parseInt('3.14')   // β†’ 3
parseInt('3.99')   // β†’ 3  (truncates, does not round)

parseInt() stops at the decimal point, truncating (not rounding) the fractional part.

parseInt Truncates

parseInt('3.14') truncates the decimal part and returns 3.

Challenge: Verify the truncation.

πŸ’‘ Hints (1)
  • β€’ parseInt stops parsing at the decimal point.