Searching through it all...

Searching through it all...

Update on how JS search, well I think, it should look like.

This is a reference to an article I wrote about building a Bee Behavior App and how it is part of a much larger picture.

link to that article below:

https://tauwindcoding.hashnode.dev/bee-behavior-app

Intro

This is how I initially wrote the code for the search function:

This is how I taught myself to write a search function,

the filter method takes a callback function as an argument, which is defined using the function keyword. Inside the callback function, the toLowerCase() method is used to convert both the behavior.name and searchTerm to lowercase, and then the indexOf() method is used to check if the lowercase searchTerm is present in the lowercase behavior.name. If the condition is satisfied, the behavior is included in the filteredBehaviors array.

Of course, there are many ways of skinning a cat as the saying goes.

The process of refactoring

A close friend of mine who is also a developer, took a look at my code and he quickly saw the method or function I used to execute the search filter he just simply said "This should just be two lines of code" and he showed me the ES6 version of this code

which is as follows:

This change alone forced me to look at the rest of my code and refactor it. a lot of the code was compressed, which made the front-end of the Bee Behaviour app run a little faster.

Letting others see your code

One of the best ways for me to continuously grow as a developer is to simply just let others see my code. In my early days of creating websites and small web apps, I used to be very hesitant to let others see my code, because I felt that I would be judged or made fun of, but As I get older I began to realize that, by others seeing the code it can help me progress much quicker.

Conclusion

The message I am trying to put across with this short article is, to let other people see your work, this can also enable you to be in other developer conversations, due to two or more developers observing your coding style or how you made the solution much easier making use of the tools, in this case, the stack they are familiar with.

Ultimately they can provide some help in your journey of development, to achieve greatness, you are going to need a bit of help along the way.