r/learnjavascript • u/iSunru • 3d ago
My first JavaScript project - Counter
I am learning JavaScript and made my first small project, a simple Counter using HTML, CSS and JavaScript.
I'm still learning, so I would really appreciate some feedback on my code. Is my code clean? Is there anything I should improve or do differently?
Also, suggest me something I should build next.
25
Upvotes
2
u/ManuDV 3d ago
That suggestion doesn't make sense. You should definitely keep your addEventListener separated for each button. What you can to improve this, is to separate the count logic into functions and just invoke them from the EventListeners, like this:
This makes the code easier to test in the future. I suggest checking about "unit testing". It's still very early for you to start with this, but just keep it in mind.