# Array Find

What It Does

Creates a sub-graph that evaluates each item in an array, returning the first item where your condition evaluates to true. You define the matching condition in the inner graph using a custom combination of nodes.

### Inputs

| Name             | Description                                            | Type   | Required |
| ---------------- | ------------------------------------------------------ | ------ | -------- |
| array            | The array to search through                            | List   | Yes      |
| *Dynamic inputs* | Any inputs you add to the inner graph will appear here | Varies | No       |

### Outputs

| Name  | Description                                                       | Type   |
| ----- | ----------------------------------------------------------------- | ------ |
| value | The first matching item found (undefined if none found)           | Any    |
| index | The position of the matching item in the array (-1 if none found) | Number |
| found | Whether a matching item was found                                 | Yes/No |

### Inner Graph Special Inputs

| Name   | Description                            | Type   |
| ------ | -------------------------------------- | ------ |
| value  | The current array item being evaluated | Any    |
| index  | The current position in the array      | Number |
| length | The total length of the array          | Number |

### Inner Graph Required Output

| Name    | Description                                     | Type   |
| ------- | ----------------------------------------------- | ------ |
| matches | Whether the current item matches your condition | Yes/No |

![Array Find Example](https://3657049418-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy0SFXZjN1sdgdxYM7QPE%2Fuploads%2FlGFJM1g2N6aQQ8bYXYGE%2FScreenshot%202025-04-17%20at%206.10.02%E2%80%AFPM.png?alt=media\&token=4befe96d-71cf-4b87-b9ee-b7157e6735b7)

### How to Use It

1. Drag the Array Find node into your graph.
2. Connect your array to the "array" input. In this example the input is a Geometric Series which outputs an array `[16, 24, 36, 54, 81, 122]`.
3. Click on the Subgraph Explorer button on the node to open and edit the inner graph.
4. In the inner graph, build your condition using the special "value" input. In this case a Compare node to check if the "value" is less than `50`.
5. Connect your condition's result to the "matches" input on the Output node.
6. Return to the main graph, where you can use the matched value, index, and found outputs. It outputs the first value that matches the condition. In this case the output is `16`.

<figure><img src="https://3657049418-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy0SFXZjN1sdgdxYM7QPE%2Fuploads%2Fn3Oj3tj0Ut6J652m7i5W%2FCleanShot%202025-05-05%20at%2019.17.41%402x.png?alt=media&#x26;token=c14331c8-49d4-44c8-bb0a-2ee4a308b4f0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3657049418-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy0SFXZjN1sdgdxYM7QPE%2Fuploads%2FYRl4tCUjuFBoc7SYT3ip%2FCleanShot%202025-05-05%20at%2019.17.55%402x.png?alt=media&#x26;token=57d510e8-df91-450e-ac01-9b107f71b71c" alt=""><figcaption><p>Subgraph explorer</p></figcaption></figure>

### Tips

* The inner graph runs once for each item in the array until a match is found.
* You can add your own inputs to the inner graph's Input node, which will appear as inputs on the main Array Find node.
* For complex comparisons, you can build any logic you need in the inner graph.

### See Also

* [**Array Filter**](https://documentation.tokens.studio/graph-engine/available-nodes/array/array-filter): Similar to Array Find, but returns all matching items instead of just the first.
* [**Find First Match**](https://documentation.tokens.studio/graph-engine/available-nodes/search/find-first-match): For simple comparison-based searching (greater than, less than).
* [**Linear Search**](https://documentation.tokens.studio/graph-engine/available-nodes/search/linear-search): For exact-match searching.

### Use Cases

* **Finding Data by Complex Criteria**: Locate items based on multiple conditions or calculations.
* **Advanced Filtering**: When your matching logic requires multiple steps or operations.
* **Custom Search Algorithms**: Implement specialized search logic for your specific data structures.
