JSFiddle - React, Tailwind, and code Playground
JavaScript
var n = 12345.12345
var c = 5; // number of decimals.
var i = parseInt(n = Math.abs(+n || 0).toFixed(c), 10) + '';
var j = (j = i.length) > 3 ? j % 3 : 0;
console.debug(i.length);
console.debug(j);