showing results for - "get specific elements from an object by using filter method"
Luciana
04 Nov 2017
1const products = [
2    { name: 'Laptop', price: 32000, brand: 'Lenovo', color: 'Silver' },
3    { name: 'Phone', price: 700, brand: 'Iphone', color: 'Golden' },
4    { name: 'Watch', price: 3000, brand: 'Casio', color: 'Yellow' },
5    { name: 'Aunglass', price: 300, brand: 'Ribon', color: 'Blue' },
6    { name: 'Camera', price: 9000, brand: 'Lenovo', color: 'Gray' },
7];
8const getProduct = products.filter(product => product.name.includes('t'));
9console.log(getProduct)
10//Expected output:
11/*
12[
13  { name: 'Laptop', price: 32000, brand: 'Lenovo', color: 'Silver' },
14  { name: 'Watch', price: 3000, brand: 'Casio', color: 'Yellow' }
15]
16*/