Before you start
- Create and update arrays of JavaScript objects
- Write functions with parameters, return values, and conditionals
- Use DOM selectors, event listeners, and form submit events
Premium JavaScript project
Render a small habit list, toggle today's progress, add new habits, and show streak-friendly status messages.
A small browser app that keeps habit data in an array, re-renders after changes, validates form input, and derives a daily progress message.
Upgrade to use the editor, browser preview, tests, and saved progress for every stage.
Project guide
Turn an array of habit objects into a working browser app. You’ll render each habit, connect buttons and a form to application state, validate new entries, update streaks safely, and derive a useful daily progress message from the latest data.
In this project, you will build a tiny browser app for tracking today's habit check-ins. The app starts with a few habit objects, renders them into the page, lets the user mark habits done, creates new habit records from a form, validates empty submissions, and updates a progress message.
Before the page can render habits, the app needs a small set of starter data. Each habit should be one object, and the full tracker should be an array of those objects.
Now the page needs to show the habit names. No streak text, classes, ids, or buttons yet. This stage is only about the basic render loop: clear the list, loop over the data, create list items, and append them.
The list already renders one item per habit. Now upgrade each item into a habit card. This stage still has no buttons. It only adds the details that later stages need.
The app now has habit cards with names, ids, and streaks. Add a button to each card and make completed cards look different.
Before a button can update a habit, the app needs a reliable way to find the habit object that belongs to that button.
Now the app can connect a click to a habit object. In this stage, clicking a toggle button should flip the habit's completedToday value and re-render the list.
The completion button works. Now add the habit-tracker rule: marking a habit done increases the streak by 1, and undoing a habit decreases the streak by 1 without going below 0.
Before the form changes the app, create a helper for one new habit record. This keeps the object shape in one place.
The form should not add blank habits. In this stage, only handle the submit event and validation message. Adding a valid habit comes next.
The form can reject blank names now. Finish the valid path: create one habit, add it to the source-of-truth array, and render again.
Before updating the summary text, write a small helper that counts completed habits. This keeps the counting rule separate from DOM updates.
The page has two text areas above the form: #habit-summary and #habit-message. These should not be separate state. They should be calculated from the current habits array.
Check the main ideas behind the habit tracker project.
Unlock the interactive stages, run the tests, and keep your code saved as you work through the full project.