codex-lv2-may-2025

Level Navigation: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Current Level: 22 23 24 25 26 27 28 29 30 31 32


đź§Ş Level 22: Use Input in Model Call

What You’ll Do

Make the AI use the user’s actual input instead of a hardcoded prompt.

Instructions

Update sendToModel() to use userPrompt instead of the scrambled-eggs prompt. Log once inside sendToModel: console.log("sending prompt:", userPrompt).

đź’ˇ Code Hints

Using variables in API calls? You’ll need to replace the hardcoded prompt with your variable. Check out the API Calls section in SNIPPETS.md for using variables in requests.

âś… Check

  1. Open your webpage in a browser
  2. Type something in the input field (like “What is the weather?”)
  3. Open Chrome DevTools (F12) and go to the Console tab
  4. Click your Send button
  5. You should see “sending prompt: What is the weather?” in the Console
  6. The AI response should be related to your actual input, not scrambled eggs
  7. If you still see the old prompt, check that you replaced the hardcoded text with userPrompt

Next: Level 25 - Render the Reply



Level Navigation: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 Current Level: 22 23 24 25 26 27 28 29 30 31 32