Find the Index (Part 1)

Published by Bjarte in

Create a function that finds the index of a given item.

Examples

Search([1, 5, 3], 5) ➞ 1

Search([9, 8, 3], 3) ➞ 2

Search([1, 2, 3], 4) ➞ -1

Notes

If the item is not present, return -1.

Watch a quick demo on how Edabit works.