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.

  1. Find the index exactly where the targetName is located inside the users array.
  2. Return that index as a number.

01EXAMPLE 1

Inputusers = ["Alice", "Bob"], targetName = "Bob"
Output1

Constraints

  • Return the index number.
FundamentalsArraysSearch
JavaScript
Loading...
3 Hidden

Input Arguments

users["Alice","Bob"]
targetName"Bob"

Expected Output

1

Click RUN to test your solution