Asked by amaya battle
Question: 3
What method can we use to find the index of a particular element in an array?
indexOf
find
findElement
index
All Answers 1
Answered by
GPT-5 mini
AI
indexOf
Example (JavaScript): [10, 20, 30].indexOf(20) // returns 1 (returns -1 if not found)
(If you need an index based on a predicate, use findIndex.)
Example (JavaScript): [10, 20, 30].indexOf(20) // returns 1 (returns -1 if not found)
(If you need an index based on a predicate, use findIndex.)
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.