This project uses semantic HTML and Bootstrap (CSS only).
JavaScript is added progressively to enhance the page — not to make it work in the first place.
Your goal is to improve behaviour, interactivity, and user experience while keeping the HTML structure intact.
Goal: Confirm JavaScript is connected and responding to user actions.
- Select the button with ID
primary-action-btn - When clicked:
- Change the button text
- Toggle its Bootstrap class (
btn-primary→btn-success)
- Stretch:
- Prevent the action from running more than once
Concepts
querySelectoraddEventListenerclassList
Goal: Introduce state and simple logic.
- Use:
#increment-btn#decrement-btn#counter-value
- Increase and decrease the displayed number
- Prevent the value from going below
0
Concepts
- Variables as state
textContent- Conditionals
Goal: Show and hide UI elements.
- Toggle visibility of
#alert-box - Use the Bootstrap class
d-none - Update the button text based on visibility
Concepts
- Boolean state
classList.toggle- UI feedback
Goal: Control content using data attributes.
- Use buttons with
data-view - Clicking a button updates the text inside
#view-output - Each view should display different content
Concepts
dataset- Event handling
- DOM updates
Goal: Provide visual feedback.
- Only one view button may be active at a time
- Apply and remove the
activeclass correctly
Concepts
- Iterating over elements
- Managing UI state
Goal: Replace browser defaults with JavaScript logic.
- Listen for the form
submitevent - Prevent default submission
- Validate required fields
- Display error messages in the UI
Rules
- No
alert()calls - Errors must be visible on the page
Concepts
preventDefault- Input validation
- DOM feedback
Goal: Improve user experience after valid submission.
- Clear the form
- Show a success message
- Disable the submit button temporarily
Concepts
- Form state
- UI feedback
- Time-based logic (stretch)
Goal: Create and insert DOM elements.
- Add a new row to the table using JavaScript
- Data may come from:
- The form
- A hardcoded object
Concepts
createElementappendChild- Template strings (stretch)
Goal: Manipulate collections of elements.
- Add a way to show only “Active” users
- Hide rows without deleting them
Concepts
- Looping over DOM nodes
- Conditional rendering
Goal: Avoid scattered variables.
- Create a single
stateobject to store:- Counter value
- Current view
- Form submission status
Concepts
- State management
- Predictable updates
Goal: Improve code readability and maintainability.
- Separate:
- Event handlers
- State updates
- UI updates
Rule
- No large anonymous functions
Concepts
- Function responsibility
- Clean code principles
Goal: Ensure graceful degradation.
- The page must:
- Load correctly without JavaScript
- Display meaningful content
Concepts
- Progressive enhancement
- Accessibility basics
Goal: Improve accessibility.
- All interactive elements must be keyboard-usable
- Add visible focus styles if needed
Concepts
- Accessibility
- Focus management
Choose any:
- Persist the counter value using
localStorage - Animate the alert using CSS classes
- Add sorting to the table
- Convert view switching into a reusable component
- Do not modify the HTML structure unless instructed
- Use clear, readable JavaScript
- Prefer small functions over clever one-liners
- Break things, then fix them
This is not about memorising syntax.
It’s about understanding how the DOM actually works.