From a869f499078311b3581d0ea98727c912e4b8e981 Mon Sep 17 00:00:00 2001 From: Andrea Bianchi Date: Mon, 23 Mar 2026 23:44:26 +0900 Subject: [PATCH] 4.2 added --- w4_2_recursion_countdown/index.html | 19 +++++++++++++++++++ w4_2_recursion_countdown/index.js | 25 +++++++++++++++++++++++++ w4_2_recursion_countdown/style.css | 15 +++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 w4_2_recursion_countdown/index.html create mode 100644 w4_2_recursion_countdown/index.js create mode 100644 w4_2_recursion_countdown/style.css diff --git a/w4_2_recursion_countdown/index.html b/w4_2_recursion_countdown/index.html new file mode 100644 index 0000000..b14babc --- /dev/null +++ b/w4_2_recursion_countdown/index.html @@ -0,0 +1,19 @@ + + + + + + + + Document + + + + + + + +

x

+ + + \ No newline at end of file diff --git a/w4_2_recursion_countdown/index.js b/w4_2_recursion_countdown/index.js new file mode 100644 index 0000000..95bf6fc --- /dev/null +++ b/w4_2_recursion_countdown/index.js @@ -0,0 +1,25 @@ +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(); +} diff --git a/w4_2_recursion_countdown/style.css b/w4_2_recursion_countdown/style.css new file mode 100644 index 0000000..578d46d --- /dev/null +++ b/w4_2_recursion_countdown/style.css @@ -0,0 +1,15 @@ +body { + display: flex; + justify-content: center; + align-items: center; + height: 100vh; + background-color: #f0f0f0; + font-family: Arial, sans-serif; + margin: auto; +} + +#countdown { + font-size: 10rem; + color: #333; + text-align: center; +}