let newArray = Oldarray.filter(callback(element, index, array));Explanation:
- The filter method returns a new array from the filtered items from the oldArray
- Items are filtered according to some condition
- To do so a callback function is used
- The callback function takes 3 arguments:
- element: The current element
- index: the index of the current element
- array: the old array
Use caseFiltering an element/elements of an array based on some condition
Join 7000+ other code newbies
Last year 7000 newbies learned how to code with me! Totally project oriented.
Subscribe and you'll get access to my classes, coupon codes for tech conferences and totally valuable article on jump-starting your career as a developer.