How Can I Improve AI Code Generation for Edge Cases in JavaScript?

Hello

I have been experimenting with AI coding assistants on Scrimba for JavaScript tasks & while they work great for common patterns; I have noticed that the AI often fails when it comes to edge cases like nested closures, unusual async flows / regex-heavy logic. :slightly_smiling_face: I am wondering if anyone has figured out techniques for refining prompts to improve consistency in these scenarios. :upside_down_face:

For eg; when I asked the AI to refactor a recursive function that included multiple error paths; it either oversimplified the output / ignored specific branches. I tried adding context & constraints in the prompt but the results still lacked nuance. :innocent:Has anyone found prompt structures that help clarify code logic expectations for the AI? Screenshots or before/after code examples would be amazing. :thinking:

I checkd Prompt Engineering Tutorial: Learn to supercharge your web dev skills with AI in this free course guide related to this and found it quite informative.

Also; I am curious if solving this kind of issue is something that falls into the job description of a Prompt Engineer. I recently came across the term and was wondering ; what is a Prompt Engineer? Is this someone who specializes in crafting effective prompts for AI coding assistants like the ones we’re using here?

Thank you !! :slightly_smiling_face: