It's a good idea to look at how other people have done things, replicate what they did, and then make very small incremental changes - verifying whether it works at each step - to see if you can move in the direction you want. Be willing to make mistakes, and even look forward to them, because you cannot learn anything about software development without making mistakes. Get proficient at easy things before attempting hard things.
As you introduce yourself to writing software, think of how easy it is to snap a pencil in half, and how it gets harder to snap each progressively smaller piece. Once you get down to 1/4 of a pencil, it's much more difficult. When writing functions, keep them as small as possible, and they will be stronger and harder to break. The function that is small and simple is like iron. The thing that drives programmers crazy is when a function slowly grows larger and larger over time, and it knows too much and does too much. Making even a small change can break the function very easily, in ways that are hard to understand. It makes programmers afraid to touch their own code, because it will collapse at the slightest breeze.