Answers for "Array find() method in 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
0

JavaScript Array Methods .find()

const list = [5, 12, 8, 130, 44];
// a find metóduson belül a number egy paraméter
// azért nem szükséges köré a zárójel, mert csak egy paramétert adunk át
// minden más esetben így kell írni:
// const found = list.find((index, number) => number > index);
const found = list.find(number => number > 10);
console.log(found);
// --> 12
Posted by: Guest on May-07-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language