The problem with ChatGTP for coding is that it's very optimistic. You can ask it to write a chunk of code, and it'll happily do it, and if it doesn't know how it'll happily lie through its teeth. It'll do it intelligently, authoratively, and without mentioning "yeah, I made up this API here, it doesn't exist).
It's a text completion system, not a General AI. It feeds the previous thousands of words that's been said between you and it, and the instructions at the root, then works out what the logical "next sentence" would be, based on the input it's seen (most of the internet).