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

Output

Callback

N/A

Video

Coming soon.

Example

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

Step

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

Result

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

Last updated