determine whole number in js code example
Example 1: javascript check if a value is an int
// The Number.isInteger() checks to see if the passed value is an integer
// Returns true or false
Number.isInteger(2); //True
Number.isInteger(90); //True
Number.isInteger("37"); //False
Number.isInteger(false); //false
Example 2: how to know if a number has a decimal number js
function hasDecimal (num) {
return !!(num % 1);
}
hasDecimal(2) // true
hasDecimal(2.345) // false