| Level Navigation: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10⚡ | 11⚡ | 12⚡ | 13⚡ | 14⚡ | 15 | 16 | 17 | 18⚡ | 19 | 20 |
User Story: As a user, I want to see my personalized Mad Libs story with my words inserted so that I can laugh at the funny result.
Generate the Mad Libs story using JavaScript template literals and form data.
Need help with template literals? Check out these snippets:
${variable} syntaxres.send() to send HTMLconst name = "Alice";
const adjective = "silly";
const story = `Once upon a time, ${name} was feeling very ${adjective}.`;
const storyTemplate = `
<h1>Your Mad Libs Story</h1>
<p>Once upon a time, ${name} went to the ${noun1} and found a ${adjective1} ${noun2}.</p>
`;
res.send(storyTemplate);
Practice with dummy variables first! Before using the real form data from req.query, create your story template with hardcoded dummy values (like name = "Alice", adjective = "silly"). This helps you:
req.query variables