The Search Party
Easy+15 XP
Mission Briefing
The search party is looking for a specific individual hiding amongst a crowd. You must find exactly where they are standing in line.
The Concept: Searching Arrays
The .indexOf(item) method searches the array from front to back for a specific item and returns its numbered index.
If the item is completely missing, it returns -1.
Example: ["A", "B", "C"].indexOf("B"); // Returns 1
The Objective
Your function receives an array users and a string targetName.
- Find the index exactly where the
targetNameis located inside theusersarray. - Return that index as a number.
01EXAMPLE 1
Input
users = ["Alice", "Bob"], targetName = "Bob"Output
1Constraints
- Return the index number.
FundamentalsArraysSearch
JavaScriptSystem handles I/O — write your function only
Loading...
3 Hidden
Input Arguments
users["Alice","Bob"]
targetName"Bob"
Expected Output
1
Click RUN to test your solution