Very close but slightly more complex than this question I have an array and I want to obtain the index of the array of the first occurrence of a value of a given object of this array.
My array has several objects of integer and text, and has an id
object of integers (which I call with this instruction wup[i].id
).
[edit] The array comes from reading a csv file with header with papaparse.
wup = ["id", "cityName", etc ... ]
[20002, "Tokyo", etc ... ]
[20003, "Goiânia", etc ... ]
It is in this id
object only that I want to find the input value and finally get the index of this input value. This is certainly using indexOf
but how to focus the search only in the id
object?
[edit] the instruction that fails is the following (try to find the occurrence of tn[iter].idOri
in the array wup
, that I expect to retrieve in the variable iOri
):
var iOri = wup.indexOf(tn[iter].idOri);
Hoping it is clear enough.