Home / Javascript Tips Generated By ChatGPT / Finding Elements in Arrays in Javascript Use .indexOf() to find the index of an element in an array. Source Code let fruits = ['apple', 'banana', 'cherry']; let index = fruits.indexOf('banana'); console.log(index); // 1