Created by Fabricio Braga
Last updated: Tue 18 March
This project is designed to help students learn JavaScript ES6 and functional programming by implementing simple, interactive features. It includes a counter implementation as a reference, and students will create six additional features using ES6 concepts.
The project includes:
- Counter (Implemented - Reference for Students)
- Clock
- Metric Converter
- To-Do List
- Random Quote Generator
- Color Changer
- Click Counter
Each feature is placed in a separate HTML file inside the /pages
directory.
To run this project, you'll need Node.js, NVM, and http-server.
First, install NVM (Node Version Manager) to easily manage Node.js versions.
Run the following command in the terminal:
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Then, restart the terminal and install Node.js:
nvm install --lts
nvm use --lts
- Download and install nvm-setup.exe
- Restart your terminal and install Node.js:
nvm install latest
nvm use latest
Once Node.js is installed, install the http-server package globally:
npm install -g http-server
Download the project using Git:
git clone https://github.com/hackthegap/course-5-es6.git
cd course-5-es6
Start the local server using:
http-server -p 8000
Now, open your browser and go to:
http://localhost:8000
/course-5-es6
│── index.html # Home page (Contains the counter as a reference)
│── styles/
│ ├── styles.css # Styling for the entire project
│── js/
│ ├── state.js # ES6 state management
│ ├── utils.js # Utility functions (pure functions)
│ ├── script.js # Counter implementation
│── pages/
│ ├── clock.html # Feature 1: Digital clock
│ ├── metric-converter.html # Feature 2: Convert distances/temperatures
│ ├── todo-list.html # Feature 3: To-do list
│ ├── random-quote.html # Feature 4: Random quote generator
│ ├── color-changer.html # Feature 5: Background color changer
│ ├── click-counter.html # Feature 6: Click anywhere counter
You need to implement the six features using JavaScript ES6 concepts.
Each page contains a title and instructions. Open the file and add the missing JavaScript functionality.
- Display a live digital clock (
HH:MM:SS
) - Use
setInterval()
to update every second
- Convert km to miles, Celsius to Fahrenheit, etc.
- Use a dropdown and an input field
- Allow users to add and remove tasks
- Store tasks in local storage for persistence
- Show a new random quote when a button is clicked
- Use an array of quotes
- Change the page's background color to a random color when clicking a button
- Increase a counter when clicking anywhere on the page
- Similar to the counter on the home page
- Use ES6 features (
let
,const
, arrow functions, template literals) - Follow functional programming principles (pure functions, no mutations)
- Use event listeners (
addEventListener
) - Keep functions modular (separate concerns, use helper functions)
- Use JavaScript modules (
import/export
)
- If you get stuck, refer to the counter implementation in
index.html
. - Google is your best friend! Search for MDN JavaScript documentation.
- Ask questions and collaborate with your classmates.
Once you have completed all features, commit and push your code to your own GitHub repository.
To push changes:
git add .
git commit -m "feature/[feature name]"
git push origin main
Good luck and have fun coding! 🚀😃