Answers for "number with 0 if digit javascript"

1

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
Posted by: Guest on March-27-2022
-1

how to know if a number has a decimal number js

function hasDecimal (num) {
	return !!(num % 1);
}
hasDecimal(2) // true
hasDecimal(2.345) // false
Posted by: Guest on June-27-2020

Code answers related to "number with 0 if digit javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language