Suppose I have below array of phrases

```
 const senetences = [
    { "text": "And a moment I Yes." },
    { "text": "Wait a moment I Yes." },
    { "text": "And a moment I Hello, Guenta, trenteuno." },
    { "text": "Okay a moment. Hello. Perfect." },
    { "text": "And a moment." },
    { "text": "And a moment I Hello, Guenta, trenteuno." },
    { "text": "Just a moment in Quinta trenteuno." },
    { "text": "And a moment in Quinta trenteuno." },
    { "text": "Wait a moment I Hello, Guenta, trenteuno." },
    { "text": "Just a moment in Quinta trenteuno." }
  ]

```

Now I search for... suppose `moment`.
So I need to get the some words before and after the exact word `moment` and their matching score in the whole array.

Example output

```
[
  "text": "And a moment", "score": 5, "percent": 50,
  "text": "moment I Hello", "score": 3, "percent": 30,
  "text": "moment in Quinta", "score": 3, "percent": 30,
  "text": "Wait a moment", "score": 2, "percent": 20,
  "text": "moment I Yes", "score": 2, "percent": 20,
  "text": "Just a moment", "score": 2, "percent": 20,
  "text": "Okay a moment", "score": 1, "percent": 10
]

```

`score` is the number of time it is occurred and the `percent` is the number of time occurred divided by the total number of sentences.

I am able to get the words after looping on `senetences` but get stuck after it.

```
const string = "moment";
const words = [];
senetences.map((a) => {
  const arrayString = a.text.toLowerCase().split(' ');
  const index = arrayString.indexOf(string.toLowerCase());
  words.push(`${arrayString[index - 2]} ${arrayString[index - 1]} ${arrayString[index]}`);
  words.push(`${arrayString[index]} ${arrayString[index + 1]} ${arrayString[index + 2]}`);
})

```

After that I got stuck how to find in the `senetences` array now.

```
const output = []
senetences.map((a) => {
    phrases.map((p) => {
    const index = a.text.toLowerCase().indexOf(p)
    if (index !== -1) {
        output.push(a.text)
    }
  })
})

```