how filter works in js code example
Example 1: how the filter() function works javascript
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const filter = arr.filter((number) => number > 5);
console.log(filter);
Example 2: filter javascript
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const filter = arr.filter((number) => number > 5);
console.log(filter);
or
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
console.log(result);
Example 3: filter in js
const filterThisArray = ["a","b","c","d","e"]
console.log(filterThisArray)
const filteredThatArray = filterThisArray.filter((item) => item!=="e")
console.log(filteredThatArray)