← Back to challenges

Find the Index

JavaScriptHardarraysstringslanguage_fundamentalsloops

Instructions

Create a function that takes an array and a string as arguments and returns the index of the string.

Examples

findIndex(["hi", "edabit", "fgh", "abc"], "fgh") ➞ 2

findIndex(["Red", "blue", "Blue", "Green"], "blue") ➞ 1

findIndex(["a", "g", "y", "d"], "d") ➞ 3

findIndex(["Pineapple", "Orange", "Grape", "Apple"], "Pineapple") ➞ 0
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Array Indexing