Answers for "javascricpt find"

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
2

js array find

const myArray = ["sun","moon","earth"];
const lookingFor = "earth"

console.log(myArray.find(planet => { return planet === lookingFor })
// expected output: earth
Posted by: Guest on May-26-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language