codex-lv2-may-2025

Lesson 5: Water Conservation App - Interactive

๐Ÿ“š Previous Lesson

Coming from Lesson 4: Mad Libs Game? Great! Now youโ€™ll make your Water Conservation App interactive by adding JavaScript functionality.


๐ŸŽฏ Learning Objectives


๐Ÿš€ Project Overview

Update your existing Week 4 Water Conservation App to make it interactive. Youโ€™ll add JavaScript functionality to the HTML wireframe you already created.

Reference: If you need to review how the Water Conservation App HTML was built, see Week 4: Bootstrap Layouts and Grid System.


๐Ÿ› ๏ธ Setup

Step 1: Open Your Project in VSCode

  1. Open VSCode
  2. Go to File โ†’ Open Folder
  3. Navigate to your water-conservation-app project folder
  4. Click Select Folder

Step 2: Download Helper Functions

  1. Download Helper Functions - Pre-built functions for common tasks
  2. Save the file as helpers.js in your project folder
  3. Important: Keep the filename exactly as helpers.js

Step 3: Add Helper Functions to HTML

Add this line to your HTML file, just before the closing </body> tag:

<script src="helpers.js"></script>

Step 4: Create Your JavaScript File

Create a script.js file in your project and include it under helpers.js in your html file.

  1. In VSCode, right-click in the file explorer
  2. Select New File
  3. Name it script.js
  4. Add this line to your HTML file, after the helpers.js script:
    <script src="script.js"></script>
    

Step 5: Learn About Helper Functions

For detailed information about available helper functions, see Helper Functions Guide.

Repeat for each html file

You should create a new JavaScript file for each of the html files you have.

Include the helpers.js and your new script file in each page.

For example, for water-bottle-screen.html, you could have a script called water-bottle-screen.js. For shower-screen.html, you could have a script called shower-screen.js.


๐ŸŒŠ Interactive Features to Add

Based on the Week 4 Water Conservation App screenshots, add these interactive features:

Original App on Code.org

Review the original app on code.org.

Screen 1 (Home/Language)

Screen 2 (Bottle Selection)

Screen 3 (Shower Timer)


Implementation Tips


๐Ÿ”— Additional Resources


๐Ÿ–ผ๏ธ Assets

Week 5 Images


๐Ÿ“š Next Lesson

Ready to build the Mad Libs game? Continue to Lesson 6: Mad Libs Game - Interactive to make your HTML wireframe interactive!


๐Ÿ† Bonus Challenge

Multiple Bottle Saves

On Screen 2, enhance the bottle selection to allow users to click the good bottle multiple times and track their conservation impact:

Implementation Ideas

This challenge adds replayability and helps users understand the cumulative impact of their conservation choices.