JavaScript + Node.js track

Part 4 · Mini Projects (Workbook)

5-sec Countdown / Mock Data Fetch

5-sec Countdown / Mock Data Fetch — Mini Projects (Workbook) in the free JavaScript + Node.js track, covering setTimeout, Promise, async/await.

Mini Projects (Workbook)1 min readFree lesson

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

  1. Print 5, 4, 3, 2, 1 at one-second intervals, then print a completion message.
  2. Clear the timer if the user cancels the countdown.
  3. Write a function that returns a Promise resolving to mock user data after a short delay.
  4. Consume the Promise once with .then() and once with async/await.
  5. Add a rejected case and handle it with try/catch or .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.

Assignment

Requirements

  • Use setTimeout and clearTimeout.
  • Do not use a busy loop for the countdown.
  • Return a rejected Promise for an unknown user id.
  • Log a clear error message instead of letting an unhandled rejection escape.

Acceptance checklist

  • The happy path works end to end.
  • Invalid input produces a useful message, not a crash.
  • The code is readable and consistently formatted.
  • You have tested at least three different inputs.

Submission

Keep the project in a folder named after the project. Include a short README.md with run instructions and one paragraph describing what was hardest.

Learn this lesson with a mentor

Work through the JavaScript + Node.js track on your own, or join a guided cohort at our Pitampura campus and online.

Call NowEnroll Now