This repository contains a complete implementation of Homework 10, focused on asynchronous JavaScript, timers, Promises, and working with third-party libraries in a modern Vite-based project.
JavaScript course is now two-thirds complete — great job! 💪 In Module 10, the focus shifts to understanding how JavaScript handles time, asynchronous operations, and Promise-based workflows.
This homework reinforces your understanding of:
- The difference between synchronous and asynchronous code
- Using timers (
setTimeout,setInterval) - What Promises are and how they work
- Promise states and lifecycle
- Handling fulfilled and rejected Promises
- Working with external libraries via NPM
It’s time to put theory into practice by building a countdown timer and a Promise generator with notifications.
goit-js-hw-10/ ├─ src/ │ ├─ js/ │ │ ├─ 01-timer.js │ │ └─ 02-snackbar.js │ ├─ pages/ │ │ ├─ 01-timer.html │ │ └─ 02-snackbar.html │ └─ styles.css ├─ public/ ├─ dist/ ├─ index.html ├─ package.json ├─ vite.config.js └─ README.md
The project is built using Vite with ES Modules and follows a clean, modular structure.
Implemented in 01-timer.html and 01-timer.js.
The goal of this task is to create a countdown timer that counts down to a user-selected future date.
- Date and time selection using flatpickr
- Validation to prevent selecting past dates
- Start button disabled until a valid future date is selected
- Countdown updates every second
- Timer stops automatically when time reaches zero
import flatpickr from "flatpickr"; import "flatpickr/dist/flatpickr.min.css"; import iziToast from "izitoast"; import "izitoast/dist/css/iziToast.min.css";
- User selects a date using flatpickr
- If the date is in the past, a notification is shown
- If the date is valid, the Start button becomes active
- On Start, the remaining time is calculated every second
- Time is displayed in
DD:HH:MM:SSformat - Values are formatted with leading zeros
- flatpickr library is correctly connected
- iziToast is used instead of
alert() - Start button is disabled on page load
- Past dates are rejected with a notification
- Future dates enable the Start button
- Timer updates every second
- Timer stops at
00:00:00:00 - Time values are properly formatted
Implemented in 02-snackbar.html and 02-snackbar.js.
This task focuses on creating Promises dynamically based on user input and handling their resolution or rejection with notifications.
- User enters a delay value in milliseconds
- User selects Promise state: fulfilled or rejected
- On submit, a Promise is created
- The Promise resolves or rejects after the specified delay
- If fulfilled: success notification is shown
- If rejected: error notification is shown
- Notification text includes the delay value
✅ Fulfilled promise in ${delay}ms
❌ Rejected promise in ${delay}ms
import iziToast from "izitoast"; import "izitoast/dist/css/iziToast.min.css";
- iziToast library is correctly connected
- Promise is created on form submission
- Delay value is taken from user input
- Promise state depends on selected radio button
- Notification appears after the specified delay
- Message content matches the task requirements
This homework demonstrates a solid understanding of asynchronous JavaScript concepts, including timers, Promises, and real-world async workflows.
The project follows modern best practices using:
- ES Modules
- Vite bundler
- NPM package management
- Third-party libraries
- Clean and readable code structure
- GitHub Repository: https://github.com/kutluhangil/goit-js-hw-10
- Live Demo (GitHub Pages): https://kutluhangil.github.io/goit-js-hw-10/