check if number is single digit javascript
function hasOneDigit(val) {
return String(Math.abs(val)).charAt(0) == val;
}
console.log(hasOneDigit(1)); // true
console.log(hasOneDigit(12)); // false
check if number is single digit javascript
function hasOneDigit(val) {
return String(Math.abs(val)).charAt(0) == val;
}
console.log(hasOneDigit(1)); // true
console.log(hasOneDigit(12)); // false
how to know if a number has a decimal number js
function hasDecimal (num) {
return !!(num % 1);
}
hasDecimal(2) // true
hasDecimal(2.345) // false
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us