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 [`split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) the first item in the nested array at `.` and use [`filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) like this:

```js
let 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']]

let result = arr.filter(a => a[0].split('.')[1] === "10")

console.log(result)
```

If you have support for [destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment), you can do:

```
arr.filter(([key]) => key.split('.')[1] === "10")

```

**Update**:

If you want to search both indexes, you can use [`includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes):

```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 getResults(arr, search){
  return arr.filter(a => a[0].includes(search) || a[1].includes(search))
}

console.log(getResults(arr, "10"))
console.log(getResults(arr, "S1"))
```
You can try this code:

```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 search(index){
  for(i = 0; i<=arr.length-1; i++){
    if(arr[i].indexOf(index)>-1){
      console.log(arr[i]);
    }
  }
 }

 search("AAAA.10");
```