Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Get specific elements from an object by using filter method

const products = [
    { name: 'Laptop', price: 32000, brand: 'Lenovo', color: 'Silver' },
    { name: 'Phone', price: 700, brand: 'Iphone', color: 'Golden' },
    { name: 'Watch', price: 3000, brand: 'Casio', color: 'Yellow' },
    { name: 'Aunglass', price: 300, brand: 'Ribon', color: 'Blue' },
    { name: 'Camera', price: 9000, brand: 'Lenovo', color: 'Gray' },
];
const getProduct = products.filter(product => product.name.includes('t'));
console.log(getProduct)
//Expected output:
/*
[
  { name: 'Laptop', price: 32000, brand: 'Lenovo', color: 'Silver' },
  { name: 'Watch', price: 3000, brand: 'Casio', color: 'Yellow' }
]
*/
Comment

PREVIOUS NEXT
Code Example
Javascript :: js get first and last day of previous month 
Javascript :: deleteicon material ui improt 
Javascript :: npm simple zip file creator 
Javascript :: javascript insertion sort 
Javascript :: nested json schema mongoose 
Javascript :: rich text react renderer 
Javascript :: expo react navigation 
Javascript :: js round 2 decimals 
Javascript :: netlify page not found on refresh vuejs vue-router 
Javascript :: inheritance in class in js 
Javascript :: how to load js in vuejs components 
Javascript :: componentdidmount in functional component 
Javascript :: how to print two arrays together 
Javascript :: monaco editor events 
Javascript :: create a style in div jsx 
Javascript :: get textarea value jquery 
Javascript :: how to import in react js 
Javascript :: counter in html and js 
Javascript :: js content editable 
Javascript :: node .env file example 
Javascript :: apollo client nextjs 
Javascript :: web3 connect to smart contract 
Javascript :: vs code file nesting 
Javascript :: js combine two arrays 
Javascript :: map in react 
Javascript :: react-data-table-component edit action 
Javascript :: how to append in javascript 
Javascript :: set javascript 
Javascript :: moves zeroes 
Javascript :: save sort order of jquery sortable 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =