Javascript Get Index Of Element In Array By Condition