The annoying habit GPT has of restating the question as the start of the answer. "How do I write a function in JavaScript to sort a list of cities by population grouped by region?
GPT: To sort a list of cities by population grouped by region, in JavaScript, would at a high level require 3 steps...."
Super frustrating when you just want the answer without the "polite professionalism"
If you can only work with GPT-3.5 model, the prompt that bumbledraven shared may still produce some explanations and provide no syntax highlighting. To solve this, you can add: "Skip prose. Skip explanation. Answer in a single code block in markdown."
Also, if you're using the playground, I'd recommend keeping the temperature low (I normally set it to 0 for this task). This will prevent any extra information such as test data, from being included. From my experience, setting the prompt I shared earlier as the system prompt produced more consistent results. However, whatever I shared is based on my own trial & error, so I'm not sure if this will work for you/in general.
GPT: To sort a list of cities by population grouped by region, in JavaScript, would at a high level require 3 steps...."
Super frustrating when you just want the answer without the "polite professionalism"