Hi how do I add comma to the numbers and also add a % at the end? I can't seem to make the code work. Thank you! Just want to make it 100,000 and then also for other numbers like 50%, have % while adding up. It's hard to find info about this.
}) $w.onReady(()=>{ $w('#text69').onViewportEnter(()=>{ let count = 99800 //start time const endTime = 100000 // end time const interval = 0.1 // interval between counts ms const counter = setInterval(() => { $w('#text69').text = String(count) // update text count === endTime && clearInterval(counter) // clears the interval when count is equal to endTime count++ // increment count }, interval) }); function countUp(){ if (count <= endTime){ $w('#text69').text = count.toLocaleString().toString(); count++; } } })
$w.onReady(()=>{
$w('#text69').onViewportEnter(()=>{
let count = 0 //start time
const endTime = 100000 // end time
const interval = 0.1 // interval between counts ms
const counter = setInterval(() => {
$w('#text69').text = String(count) // update text
count === endTime && clearInterval(counter) // clears the interval when count is equal to endTime
count++ // increment count
}, interval)
});
function countUp(){
if (count <= endTime){
$w('#text69').text = count.toLocaleString().toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "%";
count++;
}
}
})
Ref: https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript