how to check if an input is a decimal in javascript code example
Example 1: javascript how to take off a decimal
function png(){
return Math.trunc(Math.random() * 10);
}
//Removes the decimal without rounding
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