> For the complete documentation index, see [llms.txt](https://docs.emobiq.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.emobiq.com/emobiq-client/006-actions-and-visual-logic/action-reference/cordova/string/findindex.md).

# findIndex

## Description

It searches for a specific element in an array and returns the index of the first occurrence of that element. If the element is not found, it returns -1.

## Input / Parameter

| Name   | Description                                       | Input Type | Default | Options | Required |
| ------ | ------------------------------------------------- | ---------- | ------- | ------- | -------- |
| string | The array/list where in the search would be done. | Array/List | -       | -       | Yes      |
| find   | The value to find in the array/list.              | Any        | -       | -       | Yes      |

## Output

| Description                                                                   | Output Type |
| ----------------------------------------------------------------------------- | ----------- |
| Returns the index of the first occurrence and if it not found, it returns -1. | Number      |

## Callback

N/A

## Video

Coming soon.

## Example

The user wants to get the index of character "H" in a passed string.<br>

### Step

1. Call the function `console`. Call the function `findIndex` inside the `value` parameter of the `console` function.\
   string: aBcDeFgHiJ\
   find: H

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-82b36451baf6dbe44978917d01fcaba2dc142fb4%2FfindIndex-step-1.png?alt=media)

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-a769d0d73e8748e265db4147c0efd7b6dba18181%2FfindIndex-step-2.png?alt=media)

### Result

The console should return '7', the index of 'H' in the string.

## Links


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.emobiq.com/emobiq-client/006-actions-and-visual-logic/action-reference/cordova/string/findindex.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
