Fichtelgard

Dots to 1.000.000

export function addMilleDots(string: string) {
if (string.length <= 3) return string;
let splitted = string.split("");
let nowWithDots: string[] = [];
let counter = 0;
for (let i = splitted.length - 1; i >= 0; i--) {
if (!(counter % 3) && splitted.length - i > 3) {
nowWithDots.push(".");
}
nowWithDots.push(splitted[i]);
counter++;
}
nowWithDots.reverse();
return nowWithDots.join("");
}