function countDown(n) {
  if (n == 0) {
    celebrate();
    setText('Happy New Year!');
  } else {
    setText(n);
    setTimeout(() => {
      countDown(n - 1);
    }, 1000);
  }
}

const n = 10;
setText(n);
countDown(n);

// Helpers
function setText(n) {
  document.getElementById('countdown').textContent = n;
}

function celebrate() {
  const jsConfetti = new JSConfetti();
  jsConfetti.addConfetti();
}
