Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
 
PREVIOUS NEXT
Tagged: #check #number #single #digit #javascript
ADD COMMENT
Topic
Name
8+8 =