Library › Coding AI › High school students
Get clues for a grade function that gives a C for 95
Practice: Setting limits and rules. About 5 minutes.
About this exercise
Your JavaScript letterGrade function says 95 is a C. You want to find the bug yourself, so ask for exactly 3 numbered lines labeled 'Clue 1:', 'Clue 2:' and 'Try this:', each under 20 words. 'Try this:' names one score to trace by hand and what the function returns for it now. No code blocks and no fixed code, under 70 words.
Common mistakes when you ask AI for this
- Getting the fix. The AI's default is a reordered function, which skips the tracing your teacher wants you to do. Try: Say: "No fixed code. Clues only."
- Chasing the wrong idea. Your note suggests > instead of >=, and the AI may go along with it. Try: Ask: "What does the order of the checks do?"
- No score to trace. Without a specific score, 'trace it' is hard to start. Try: Add: "Try this: one score to trace and what it returns now."
- A long explanation. The AI explains if/else from scratch. Try: Add: "Exactly 3 numbered lines, each under 20 words."
What a strong prompt includes
- Asks for clues, not the fix
- Gives the labels
- Asks for a score to trace
- Sets the number of lines
- Caps each line
Related exercises
- Add a cron line that matches the others in a crontab (Coding AI · Product managers)
- Add dark mode by overriding your existing CSS variables (Coding AI · Software developers)
- Add input checks to your number guessing game (Coding AI · High school students)
- Add input validation to a Java method with exact messages (Coding AI · Software developers)
- Add labels to a signup form without rewriting the page (Coding AI · High school students)