Question: I have a set of arrays :

```
var arr = [ 
[ 'AAAA.10', 'S10' ],
[ 'AAAA.10', 'S11' ],
[ 'AAAA.12', 'S12' ],
[ 'AAAA.13', 'S13' ],
[ 'AAAA.14', 'S14' ] ]

```

I want to search the array values if any matches found i want to return whole array.

If im searching like `10` then it should check for array values if matches found (So the match is `AAAA.10`) then it should return whole array like this: `[[ 'AAAA.10', 'S10' ], [ 'AAAA.10', 'S11' ]]`.

I tried with the code below but its not working :

```
console.log(arr.find('10'));

```

Please help me to achieve the output.

Answer: 
You can use `Array.find` on each nested array to check if it contains the required string then accumulate the results using `Array.reduce`:

```js
var arr = [ [ 'AAAA.3', 'S3' ],
[ 'AAAA.4', 'S4' ],
[ 'AAAA.5', 'S5' ],
[ 'AAAA.6', 'S6' ],
[ 'AAAA.7', 'S7' ],
[ 'AAAA.8', 'S8' ],
[ 'AAAA.9', 'S9' ],
[ 'AAAA.10', 'S10' ],
[ 'AAAA.10', 'S11' ],
[ 'AAAA.12', 'S12' ],
[ 'AAAA.13', 'S13' ],
[ 'AAAA.14', 'S14' ] ];

function searchStr(search){
  const output = arr.reduce((acc, ele) => {
   let arr = ele.find(str => str.includes(search));
   return arr ? acc.concat(ele) : acc;
  }, []);  
  return output;
}
console.log(searchStr("10"));
```
You can use `filter` to return a new array and inside the `filter` call back check if the inner elements ends with matching value & use `endsWith` for that.

You can use `includes` if you want to get array of elements which `includes` the `val` at any position

Also note this will return if both the element inside the nested array have matching character but if you use `||` instead of `&&` it will also return `['AAAA.10', 'S11']`

```js
var arr = [
  ['AAAA.3', 'S3'],
  ['AAAA.4', 'S4'],
  ['AAAA.5', 'S5'],
  ['AAAA.6', 'S6'],
  ['AAAA.7', 'S7'],
  ['AAAA.8', 'S8'],
  ['AAAA.9', 'S9'],
  ['AAAA.10', 'S10'],
  ['AAAA.10', 'S11'],
  ['AAAA.12', 'S12'],
  ['AAAA.13', 'S13'],
  ['AAAA.14', 'S14']
]

function findNestArray(val) {
  return arr.filter(function(item) {
    if (item[0].endsWith(val)) {
      return item
    }
  })
}
console.log(findNestArray('10'))
```