
Scenario
We have a an array of objects:
const books = [
{'id':1, 'name': 'Removing Plastic from the Ocean'},
{'id':2,'name':'Universal Citizenship'}];We want the find the name of the book with id 2 .
Approach
const name = books.find(x => x.id === 2).name;