Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AnkitMaheshwariIn/a9bf1818cd709ac473442efb444d2d6c to your computer and use it in GitHub Desktop.
Save AnkitMaheshwariIn/a9bf1818cd709ac473442efb444d2d6c to your computer and use it in GitHub Desktop.
How would you check if a number is an integer?
function isInt(num) {
// check if remainder left when we divide by 1
return num % 1 === 0;
}
// call isInt function
console.log(isInt(4)); // true
console.log(isInt(12.2)); // false
console.log(isInt(0.3)); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment