filter js w3schools code example
Example 1: javascript filter
const filtered = array.filter(item => {
return item < 20;
});
Example 2: filter in js
const filterThisArray = ["a","b","c","d","e"]
console.log(filterThisArray)
const filteredThatArray = filterThisArray.filter((item) => item!=="e")
console.log(filteredThatArray)
Example 3: filter javascript
function filter(array, filterfunc) {
let filteredArray = [];
for (let i = 0; i < array.length; i++) {
let result = filterfunc(array[i], i, array);
if (result) {
filteredArray.push(array[i]);
}
}
return filteredArray;
};