Coming from Lesson 3: Build a Clicker App? Great! Now you’ll learn about input handling and string manipulation with a fun Mad Libs game.
Mad Libs are word games where players fill in blanks to create funny stories. This lesson teaches:
Note: You’ll be using your existing repository from Week 4 to add Mad Libs functionality.
Start by playing the game to understand how it works:
// Get input value
var userInput = document.getElementById("inputId").value;
// Combine strings with template literals
var story = `The ${adjective} ${noun} ${verb} over the ${place}.`;
// Alternative: Combine strings with + operator
var story = "The " + adjective + " " + noun + " " + verb + " over the " + place + ".";
// Display result
document.getElementById("outputId").innerHTML = story;
Ready to build in VSCode? Continue to Lesson 5: VSCode Projects to create your own Mad Libs game and enhance the Water Conservation App!