Debug this function
Pinpoint the root cause of any broken function and get a corrected version with a clear explanation. Ideal for any language when the expected and actual behaviour diverge.
Preview
Copy prompt
Here is a function that is not working as expected: [Paste code]. The expected behavior is [Expected] but the actual behavior is [Actual]. Walk me through identifying the root cause step by step, explain why the bug occurs, and provide a corrected version. Add a short comment next to each change explaining what was wrong and why the fix resolves it.
More
Debugging
Prompts
