DEV Community

Oluwanifemi Latunde
Oluwanifemi Latunde

Posted on

Remove Element

Today is day 2 of the #I4G10DaysOfCodeChallenge and the challenge for today was to remove a specific element from an array or list.

I solved the challenge using python and JavaScript.
I used the inbuilt remove method for python and the inbuilt splice method for JavaScript.

Image of the solution using Python3

I looped through each content of the array and did a check to know if the specific number was reached, if it was then it should be removed from the array.

The splice method of JavaScript can be used if you are aware of the value you wish to delete from an array. You must first determine the target item's index. Then, you start by removing one element while using the index as the start element. To avoid skipping the next member in the array when you wish to remove many elements, simply decrement the index variable.

Image of the solution using JavaScript

Thank you.

Latest comments (4)

vishwastyagi profile image
Vishwas Tyagi

Congratulations! Keep going.

nifilat profile image
Oluwanifemi Latunde

Thank you so much

khojo_kwofie profile image
Evans Kojo Kwofie

Good simple solve!

themfon profile image

Doings! 🤲🏾