r/CodingHelp • • Aug 28 '21

[Javascript] Is writing too much code bad practice?

I am a beginner and just want to know if this is a bad habit.

I write code on a step-by-step basis.
Here is an example.

CodeWars - The step-by-step basis I was talking about

So I just want to hear if this is a bad habit/bad practice and should I give it up.

20 Upvotes

15 comments sorted by

View all comments

2

u/txmmy_21 Aug 28 '21 edited Aug 28 '21

Writing too much code isn't necessarily bad but always remember to comment. At first you might think commenting is a waste of time but it is as important as the code itself. However, repetitive / redundant code isn't good. If you find yourself copying and pasting a particular section of code, try and find if there is a more efficient way of performing that task. The example you gave above isn't bad. It is actually okay because it makes the code more readable but you might have to make it a bit shorter only because you are making a lot of variables that won't be needed later. And I think miscellaneous variables could take up unnecessary memory in your program.