JavaScript Seperate String Number с точками

const strNumber ="12342521"; 
let reverseStrNumber = strNumber.split("").reverse().join("");
let counter1 = 0;
let counter2 = 0;
let formattedStrNumber= "";
for (let x of reverseStrNumber) {
  formattedStrNumber += x;
  counter1++;
  if(counter1 % 3 === 0){
  	counter1 = 0;
    if(!(reverseStrNumber[counter2+1] === undefined)){
    	formattedStrNumber += '.';
    }
  }
  counter2++;
}
formattedStrNumber = formattedStrNumber.split("").reverse().join("");
document.getElementById("demo").innerHTML = formattedStrNumber;
Eager Elephant