Answers for "how to match item in array javascript"

50

javascript find

const inventory = [
  {name: 'apples', quantity: 2},
  {name: 'cherries', quantity: 8}
  {name: 'bananas', quantity: 0},
  {name: 'cherries', quantity: 5}
  {name: 'cherries', quantity: 15}
  
];

const result = inventory.find( ({ name }) => name === 'cherries' );

console.log(result) // { name: 'cherries', quantity: 5 }
Posted by: Guest on July-11-2020
1

find in js

The first element that will be found by that function
const f = array1.find(e => e > 10);
Posted by: Guest on August-31-2020

Code answers related to "how to match item in array javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language