Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get number right of the dot length javascript

var x = 23.453453453;
x.countDecimals(); // 9

var countDecimals = function (value) {
    if(Math.floor(value) === value) return 0;
    return value.toString().split(".")[1].length || 0; 
}
 
PREVIOUS NEXT
Tagged: #number #dot #length #javascript
ADD COMMENT
Topic
Name
7+2 =