What are some common pitfalls when using global variables in JavaScript for multiple countdown instances?

One common pitfall when using global variables in JavaScript for multiple countdown instances is that they can lead to conflicts and unintended interactions between the countdowns. To solve this issue, you can encapsulate each countdown instance within its own object or function scope to keep track of its own state and avoid global variable conflicts. ```javascript // Encapsulate countdown logic within a function function Countdown(duration, elementId) { let timeLeft = duration; const timer = setInterval(() => { timeLeft--; // Update countdown display in element with id elementId document.getElementById(elementId).innerText = timeLeft; if (timeLeft <= 0) { clearInterval(timer); } }, 1000); } // Create multiple countdown instances new Countdown(60, 'countdown1'); new Countdown(120, 'countdown2'); ```