Finding the Index of an Element in an Array in Javascript


Use .indexOf() to find the position of an item in an array.

Source Code

let fruits = ["Apple", "Banana", "Orange"];
let bananaIndex = fruits.indexOf("Banana");
console.log(bananaIndex); // 1
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments