-4

I have array like this:

let A = [1,2,3,4,5,6,7]

and I want Which parameter is equal === 4

array.includes(4) //true

Top code just show me true but i want show me array[3] is 4

DONT NOW
  • 7
  • 1

1 Answers1

3

You should use .indexOf() instead of .includes()

let A = [1,2,3,4,5,6,7]
let index = A.indexOf(4)
 

Output : index = 3

Suyash Gaur
  • 2,481
  • 2
  • 9
  • 22