Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Is Whole Number

Numbers, Dates & Timerseasy

Course · Section 12: Numbers, Dates, Intl and Timers · Lecture 181: Converting and Checking Numbers

Implement `isInt(n)` returning whether `n` is an integer.

Sample tests

Input: isInt(5)
Output: true
Input: isInt(5.5)
Output: false

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • The global isNaN/parseInt are not integer checks.
Approach & explanation (try first)

Number.isInteger returns true only for whole numbers.

Loading...
⌘/Ctrl + Enter

Run your code to see results.