-1

I have an array that looks like this:

listOf:[
  {name: "One", title: "Get Clown"},
  {name: "Two", title: "Find Bob"},
  {name: "Three", title: "Get Josh"}
]

How can I get one element by the other? For example, get the title "Find Bob" by looking for the name "Two".

Nick Parsons
  • 45,728
  • 6
  • 46
  • 64

1 Answers1

2
listOf.find(element => element.name === 'Two').title
NewVigilante
  • 1,291
  • 1
  • 7
  • 23