filter with function javascript code example
Example 1: filter javascript array
var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
console.log(result);
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: JavaScript Array Methods .filter()
const colours = ['green', 'black', 'dark-orange', 'light-yellow', 'azure'];
const result = colours.filter(colour => colour.length > 6);
console.log(result);