1var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
2
3const result = words.filter(word => word.length > 6);
4
5console.log(result);
1var numbers = [1, 3, 6, 8, 11];
2
3var lucky = numbers.filter(function(number) {
4 return number > 7;
5});
6
7// [ 8, 11 ]
1// Filter items
2function filterItems(e) {
3 // Convert to lowercase
4 var text = e.target.value.toLowerCase();
5 // Get lis
6 var items = itemList.getElementsByTagName('li');
7 // Convert to an array
8 Array.from(items).forEach(function(item) {
9 var itemName = item.firstChild.textContent;
10 if (itemName.toLowerCase().indexOf(text) != -1) {
11 item.style.display = 'block';
12 } else {
13 item.style.display = 'none';
14 }
15 });
16}
1const rebels = pilots.filter(pilot => pilot.faction === "Rebels");
2const empire = pilots.filter(pilot => pilot.faction === "Empire");