codex-lv3-may-2025

Level Navigation: 1 2 3 4 5 6 7 8 9 10⚡ 11⚡ 12⚡ 13⚡ 14⚡ 15 16 17 18⚡ 19 20

Level 9: Code Organization and Best Practices

User Story: As a developer, I want to organize my code with comments and good practices so that my Mad Libs application is easy to read and maintain.

What You’ll Do

Organize your code for maintainability and follow best practices.

Instructions

💡 Code Hints

Need help with organization? Check out these snippets:

Show Me: code comments
// Server setup - this creates our Express application
const express = require('express');
const app = express();

// Static file serving - allows us to serve HTML, CSS, and JS files
app.use(express.static('public'));

// Routes - this handles requests to different URLs
app.get('/', (req, res) => {
    res.send('Mad Libs! Start here: <a href="/mad-libs-form.html">Create New</a>');
});
Show Me: descriptive variable names
// Get the story template
const storyTemplate = `Your story here...`;

// Extract user input from form data
const userName = req.query.name;

// Create the personalized story content
const storyContent = `Once upon a time, ${userName} went on an adventure.`;

// Wrap the story in HTML for display
const storyResponse = `<div class="card">${storyContent}</div>`;

✅ Check

  1. Your code should be well-commented - add comments to explain what each section does
  2. Variable names should be descriptive
  3. All functionality should work correctly
  4. Code should be easy to read and understand - comments help with this!