-1

Right now I have an array that looks like this

    const array = [
    {
      value: 'received',
      title: 'Hjá Birgja',
    },
    {
      value: 'pending',
      title: 'Yfirstandandi',
    },
    {
      value: 'processing',
      title: 'Í vinnslu',
    },
  ]

and I would like this to return true

if(array.includes('processing'){
  // do something
}
meowzart
  • 75
  • 1
  • 8
  • Why not just make a looping function somewhere and just call that? Then you don't have to write a new loop in your code each time -- just call your function that packages up that logic. – Jeremy Harris Feb 21 '20 at 13:48
  • `array.includes('processing')`: the array don't include `processing`, it's one of its object that contains, you need to loop over the objects and find if one of them have in its value the "processing" – Calvin Nunes Feb 21 '20 at 13:50

1 Answers1

0

not exactly what you wanted since i'm not sure if you only wanted to search the value key but here's a solution

if (array.find(i => i.value === 'processing')) {
  // do something
}
Gene Sy
  • 1,325
  • 2
  • 10
  • 17