-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilter-find.js
More file actions
22 lines (20 loc) Β· 841 Bytes
/
filter-find.js
File metadata and controls
22 lines (20 loc) Β· 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Hazrat Ali
// University Of Scholars
const numbers = [5, 13, 7, 41, 30, 5, 2, 19];
const bigNumbers = numbers.filter(number => number > 20);
const smallNumbers = numbers.filter(number => number < 10);
// console.log(smallNumbers);
// Filter Find js
const products = [
{ name: 'water bottle', price: 50, color: 'yellow' },
{ name: 'mobile phone', price: 15000, color: 'black' },
{ name: 'smart watch', price: 3000, color: 'black' },
{ name: 'sticky note', price: 30, color: 'pink' },
{ name: 'water glass', price: 3, color: 'white' }
];
const expensive = products.filter(product => product.price > 100);
// console.log(expensive);
const blacks = products.filter(product => product.color == 'pink');
// console.log(blacks);
const whiteItem = products.find(product => product.color == 'black');
console.log(whiteItem);