I am starting a new mini series on JavaScript. I’m starting it from zero. Anyone can start learning from here. My goal is helping others while learning! I know about JavaScript and I’m working on a MERN tech stack. But I think it is not a bad idea to revise the JavaScript from scratch and helping others in this time. If you have any questions, shoot on the comment session or you can directly ask me in my social media. Social media links are in the last part of today’s lesson! Let’s learn JavaScript together.

Refactor our last tutorial code — JavaScript Series — Part 29

A full series to learn the JavaScript from zero

Muhammad Ali
3 min readFeb 26, 2020

In our last code there is a easy bug, if you just add a empty anime name then it inserted in the list.

To solve this we just need to add a logic that value string length should be gretter than 1 or as much character you want

This code is kinnda messy right ? Let’s make it better together.

We’ll start take the anonymous out for the addEventListener.

Now let’s add a new function to get the input value

We can break our code into a new function for just creating a list item

Now we have another bug, did you noticed yet ? When we add a new anime list, the input field doesn’t clear after that

To solve this we just need to add a single line to clear the value

Do you liked the tutorial ? Turn on the post notification to find what coming next!

Other posts of this series can be found here — https://blog.nerdjfpb.com/tag/javascript/

Originally it published on nerdjfpb blog. Check the git for codes.

you can connect with me in twitter, linkedin or instagram

--

--

Muhammad Ali
Muhammad Ali

Written by Muhammad Ali

An otaku who loves computer. Love to write and help others through my work. Have a look on my Instagram https://www.instagram.com/nerd_jfpb/

No responses yet