ChatGPT 4 is pretty decent at checking code for any mistakes, and it can generate pretty good code if you can describe what you want very well. But sometimes it does give you code with a slight mistake or two, so what I normally do is give it the code in a new chat and get it to check it itself