const numbers = [2, 4, 5, 3, 8, 9, 11, 33, 44];
const findIndex = numbers.findIndex((number) => number == 5);
console.log(findIndex)
//Expected output: 2
let myList = ['foo', 'bar', 'qux'];
myList.indexOf('bar'); // 1
const beasts = ['ant', 'bison', 'camel', 'duck', 'bison'];
beasts.indexOf('bison'); //ouput: 1
// start from index 2
beasts.indexOf('bison', 2); //output: 4
beasts.indexOf('giraffe'); //output: -1
// find index of array in javascript
const number = [1,6,2,8,1,0,4,2,7,5,4,1];
const index = number.findIndex(item => item === 8);
console.log(index)
var fruits = ["Banana", "Orange", "Apple", "Mango"];
return fruits.indexOf("Apple"); // Returns 2
// find index of array item; test values using a function
const arr = ['A','B','C'];
const index = arr.findIndex((item) => item === 'B'); // index == 1
array.indexOf("item");
const index = array.findIndex((param)=> param.name == "jimmy")
/* param will iterate on every value of the array looking for
that one element that fits the criteria that is indicated in arrow function
besides it */
let first = fruits[0]
// Apple
let last = fruits[fruits.length - 1]
// Banana