1var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
2
3const result = words.filter(word => word.length > 6);
4
5console.log(result);
1const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
2
3const result = words.filter(word => word.length > 6);
4
5console.log(result);
6// expected output: Array ["exuberant", "destruction", "present"]
1const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
2
3const filter = arr.filter((number) => number > 5);
4console.log(filter); // [6, 7, 8, 9]
5
1const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
2
3const filter = arr.filter((number) => number > 5);
4console.log(filter); // [6, 7, 8, 9]
5
6or
7
8const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
9
10const result = words.filter(word => word.length > 6);
11
12console.log(result);
13// expected output: Array ["exuberant", "destruction", "present"]
1const filtered = array.filter(item => {
2 return item < 20;
3});
4// An example that will loop through an array
5// and create a new array containing only items that
6// are less than 20. If array is [13, 65, 101, 19],
7// the returned array in filtered will be [13, 19]