I have this array:
var array = [400, 4000, 400, 400, 4000];
How can I get the index of the first element with value greater than 400?
You can use findIndex here
check this snippet
var array = [400, 4000, 400, 400, 4000]; var index=array.findIndex(function(number) { return number > 400; }); console.log(index);