Files
IRTH/client/src/calc/formatNumber.ts
T
2024-06-14 13:54:55 +05:00

20 lines
408 B
TypeScript

const formatNumber = (
num: number,
separator: string,
countToSeparate: number,
firstIndexSeparator: number
) => {
const notFormated = [];
const text = `${num}`;
for (let i = 0; i < text.length; i++) {
if (i % countToSeparate === firstIndexSeparator) {
notFormated.push(separator);
}
notFormated.push(text[i]);
}
return notFormated.join("");
};
export { formatNumber };