Find the Index (Part 1)

Published by iamissam in

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

Examples

search([1, 5, 3], 3) ➞ 2

search([1, 9, 9], 9) ➞ 1

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

Notes

If the item is not present, return -1.

Watch a quick demo on how Edabit works.