I have two arrays want to get index of each item in array2
like below:
const array1 = ['apple', 'orange', 'banana', 'mango', 'watermelon'];
const array2 = ['apple', 'orange', 'watermelon'];
const x = array2.map(item2 => array1.findIndex(item => item === item2 ));
console.log(Math.max(x)); // output: NaN
And then I am trying to get max number from x
array but it output returned NaN. How can I get max number in this array?