How do I make myself think and write code like a programmer?

Hi guys, I have a question… I started learning the basics of JavaScript yesterday on codecademy and I am absorbing knowledge fairly quickly (I still make couple mistakes of course, but that’s not what I am worried about).

I just did the ‘dog years’ problem to test my knowledge in variables and before following the instructions on the left I wanted to see if I could solve the problem on my own.

Good news is that I was able to arrive to the correct answer, bad news is that my code looks horrible compared to the step by step instructions.

How do I make myself think and write code like a programmer? I am concerned about this. I am attaching a screenshot with both codes so you can see what I mean.

Thank you for any advice.

You just started yesterday and you’re putting this much pressure on yourself? You’ve got to cut yourself some slack here. Do you have previous programming experience?
Learning to think computationally isn’t instantaneous. It takes time and practice/repetition. Honestly? Try to not worry so much right now. Keep up a routine-set aside a couple hours a day and learn. Take notes, write code examples, whatever works for you. But also learn to take breaks and do something else. You’ll get there… but you’ll get stuck and frustrated and that’s okay! Everybody does. It’s part of the process. Keep at it. :slightly_smiling_face:


I’ll add to Lisa’s great answer which is all true.

I think it’s useful to know you’re not expected perfection on the first go-around. So it’s pretty normal to have the mindset: “ok, I did it as best as I know how, but there’s always the chance I might miss something”. Code review is a thing and nobody writes perfect code every time (a junior dev can find a mistake in a team lead’s code change for example).

It’s a team sport at the end of the day (in many settings, excluding solo endeavors).


Yea, i agree with everyone else here. Give yourself sometime at least before questioning yourself. You’re literally just getting started. I just want you to know it takes maybe a year or so to fully understand the full fundamentals so please dont think once you start youre already a pro


Repetition. You will over time begin to morph your thought processes into that of a computer. So much so that you will reach a point in your life like myself where even in conversation I am saying, “Well if Ludie is going to be late we’ll miss the previews. Else we will see everything new thats going to be in theatres soon.”

P.s. you will also learn rather quickly that there are multiple ways to solve a problem. It will simply boil down to which answer is more suited for the resolution of the problem.

1 Like

Hi Lisa,

Thank you for your kind words. I normally get into things head first and I do go through them at 100 miles an hour, I am still learning how to pace myself and take it one step at a time.

I will try to apply your advice, thank you again and thanks to everyone else who replied to this post!

1 Like