Array.indexOf()
Get the index of an item in an array. It returns the index of the item if it’s in the array, and -1
if it’s not.
let sandwiches = ['turkey', 'tuna', 'ham', 'pb&j'];
// returns 0
sandwiches.indexOf('turkey');
// returns 3
sandwiches.indexOf('pb&j');
// returns -1
sandwiches.indexOf('grilled cheese');