-1

I basiaclly have a block of text that I put into a array , how would i be able to find a specific value and return the full line. something like array['bob 123'.'joe 112','sam 888'] if (array.contains('joe')){ log the full joe 112 }

Kevin h
  • 87
  • 8
  • 2
    `arr.find(e => e.includes('joe'))` – ASDFGerte May 14 '21 at 17:41
  • Thanks i been trying to get that to work for like an hour and just couldn't get it. – Kevin h May 14 '21 at 17:44
  • can you elaborate? What do you mean with "full line"? Do you want to return the full line of the original text? Or just the one item of the array, that contains "joe" (or whatever) – PixAff May 14 '21 at 17:48
  • I needed the full line of the text containing a specific word. like im searching for names and numbers in a array. I just totally forgot about .find() – Kevin h May 14 '21 at 17:50

1 Answers1

1

You can use find function.

array.find(a => a.includes("joe"));
Khaled
  • 46
  • 1
  • 5