Also, for me, I approach things conceptually. Syntax, you can always look up in a book. But concept, you use your imagination. If you train your brain for problem solving, you may be able to outline the steps to take to get to a solution. Once you can figure out the steps, then you can translate the steps into code. If I approached a coding problem by saying "how can I use arrays to make a 3d bridge?" I've already boxed myself into a corner because I've decided on a method before even approaching the problem. If the real problem is getting a vehicle across a chasm then I might have to ask myself other questions - of which may be making a bridge.
If I ask myself "what goes into making a 3d bridge?" then that opens up a whole other set of possibilities and other questions including "do I even need a bridge if too much goes into making it?"
So in general, the syntax of the code (what the commands are and how to use them) you can glean from documentation and examples. When you have the steps of your idea outlined to a solution, then you can start applying code to each step. If you planned your steps well enough, then you should be able to code them in pretty much any language as long as you have the syntax and methods of that language available. So eventually, it becomes less of a case of retention, and more a case of conceptualising, planning, organizing, and application. You'll start to develop methods in your own brain on how to approach common problems. For example, If you want to output some words on the computer screen, you probably know there's a Print command. Well there's the equivalent of that in a hundred other languages as well. You may not know all of the various syntax, but you understand the method: Print "some kind of string".
Enjoy your day.