filter node js array 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 array js
const arr = ['pine', 'apple', 'pineapple', 'ball', 'roll'];
const longWords = arr.filter(item => item.length > 5);
console.log(longWords); // ['pineapple']