From 2e59fda90afb8e45cb1d637cbe6e53dcf76b3da6 Mon Sep 17 00:00:00 2001 From: Zvonimir Rudinski Date: Sun, 21 Sep 2025 13:34:24 +0200 Subject: [PATCH] format number using Intl --- index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 5e443a5..0e3c199 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ -const regularFart = new Audio("fart-83471-fixed-regular.flac"); -const critFart = new Audio("fart-4-228244-fixed-crit.flac"); +const regularFart = new Audio("fart-83471-fixed-regular.flac"); +const critFart = new Audio("fart-4-228244-fixed-crit.flac"); +const countFormatter = new Intl.NumberFormat('en-US', { notation: "compact" }); const farts = [ regularFart, @@ -139,7 +140,8 @@ for (let fart of farts) { // TODO: change it to onmousedown (it stopped working after separating button and label) clickMe.onclick = () => { counter += 1; - popupText.innerText = counter + "🍑💨"; + const formattedCount = countFormatter.format(counter); + popupText.innerText = `${formattedCount} 🍑💨`; fireEvents(); };