One of the most common pitfalls I see junior developers fall into is getting frustrated or giving up when they realize they've made a mistake.
I get it. It never feels good to make mistakes in your work.
The problem is that coding is a very difficult concept to work with.
There's tons of things that can go wrong. Tons of things you need to learn the hard way. Tons of little "gotchas" that will catch you off guard. It's unreasonable to think you'll be a coding expert early on in your career and be able to avoid all of these.
That's why it's so crucial that you don't get stuck on your mistakes. Even if you spend several hours or days going down a wrong path, only to realize your mistake way later. And it certainly won't help if your only takeaway from such experiences are that you're "not smart enough" or "not cut out for coding".
The best thing you can do in such situations is simply learn as much as possible from the experience - and then move on.
Nobody will win if you beat yourself up over it. But if you can reframe your mindset to see it as a learning experience instead, you'll greatly reduce the chances of making a similar mistake in the future.
And the more you practice this way of thinking, the easier coding will get. Eventually you'll be able to spot your mistakes before making them.
Fail. Learn. Repeat.
That's the formula for learning to code.
I'm Mads Brodt — a developer, author, teacher, creator and blogger. To keep up with all of my writing, follow me on Twitter or sign up with your email above 👆