DEV Community

Discussion on: How Do You Approach Your Coding Problems

bairrada97 profile image
bairrada97 • Edited on

Trying to ask for help when you really dont know how to solve the problem. Sometimes people ask for help, "why my code dont work" and in the end Its just a typo on code.
This example It's hard not to google unless you know the Formula.
More you practice more you'll know how to approach the coding problems, It just take time and you'll learn it naturally, don't worry.

An example, you have to do a Filters for a list of items with pagination. There are a lot of different ways to build this.

Try to split the problem in small problems, sometimes people know If's and else, for, objects, arrays and they can't build something more complex despite this complex thing have everything they know.

Let's see I need to build filters page with a list and a pagination, in this case we dont have server side so this is how I approach:

I create an object with all information about my list and render on DOM.
I create filters, lets think about categories, we have Math, History and English(It's our filters).
I need to know what items on our list belongs to each category, on my object I already have this information, on my filters maybe I have a data attribute that I can match with my the item Category. If I click on Math I'll check for every Item on my list that matches with this category and then It's just show this items and hide the others.

After you finish, in 6 months you'll look through your code and you'll think you could do it in another way. Will always be like this.

There are many ways to build this, and if you have server side will be more.

This is an example of how I approach a problem