I tried with filter() function but I'm not sure about returning index and value using that. here's sample code that I tried.
var names = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
const name = names.filter((name, index) => name === 'G' ? console.log(${index}: ${name}) : null)
here variable name is useless because on call back I'm returning nothing.
However, I can access index and name inside callback but not sure about returning both.