Every line of 'javascript format number 2 digits' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
99 function format2Digits(num) { 100 return num < 10 ? '0' + num : num; 101 }
4 export function addDigits(num) { 5 let sum = 0; 6 7 for (let n of num.toString()) { 8 sum += +n; 9 if (sum >= 10) { 10 sum = sum - 9; 11 } 12 } 13 14 return sum; 15 }
61 function groupDigits(num) { 62 var ret = ""; 63 while (num.length > 3) { 64 ret = "." + num.slice(num.length - 3) + ret; 65 num = num.substring(0, num.length - 3); 66 } 67 ret = num + ret; 68 69 return ret; 70 }
240 function twoDigitsFormat(num) { 241 return (num < 10) ? '0'+ num : num; 242 }
107 function twoDigits(n) { 108 return n < 10 ? '0' + n : '' + n; 109 }
167 function floatDigits(n) { 168 return (n = String(n)).slice(n.indexOf('.')).length - 1; 169 }
37 function padNumber(n, digits) { 38 var s = "" + n; 39 for (var i = 0; i < digits - s.length; i++) { 40 s = "0" + s; 41 } 42 return s; 43 }
31 function digits3(n) { 32 return n < 100 ? '0' + digits2(n) : n ; 33 }
50 export function formatDecimal8 (num, locale) { 51 return formatDecimal(num, locale, 0, 8) 52 }
110 function toHexDigit (number) { 111 const digits = '0123456789abcdef' 112 return digits.charAt(number >> 4) + digits.charAt(number & 0x0f) 113 }