Project brief
Build a five-second countdown and a mock data fetch. The first uses timers; the second simulates an asynchronous request with a Promise and async/await.
This is a workbook project in the JavaScript track. It has no single prescribed solution: build it in your own file, test it in the browser or Node, and compare your result with the checklist below.
What you will practise
- setTimeout
- Promise
- async/await
Build it step by step
- Print 5, 4, 3, 2, 1 at one-second intervals, then print a completion message.
- Clear the timer if the user cancels the countdown.
- Write a function that returns a Promise resolving to mock user data after a short delay.
- Consume the Promise once with
.then()and once withasync/await. - Add a rejected case and handle it with
try/catchor.catch().
Stretch goal
Add one feature that is not in the list above, then write down why you chose it and what you had to change. Keep the feature small enough to finish in one sitting.
Before you move on
- The project runs without errors in a fresh browser tab or Node process.
- Empty, missing and invalid inputs are handled deliberately.
- The code is split into small functions with clear names.
- You can explain every line you wrote.
Topics: setTimeout, Promise, async/await.