I am confused between the difference between the two function indexOf and find Index in an array.
The documentation says
findIndex - Returns
Simple - What kind of array structure are you using?
findIndex(); indexOf()."I want to find the index in an array of objects, with the key of "Orange".
let fruits = [
{ type: "Apple", quantity: 9 },
{ type: "Banana", quantity: 2},
{ type: "Orange", quantity: 8},
{ type: "Pear", quantity: 777}
];
let myIndex = fruits.findIndex(fruit => fruit.type === "Orange"); // Returns 2.
"I want to find the index in a simple array".
let fruits = [ "Apple", "Banana", "Pear", "Orange"];
let index = fruits.indexOf("Orange"); // Returns 3.