I'm using this JavaScript to iterate through an array and find a matching array element:
var remSize = [],
szString, remData, remIndex, i;
for (i = 0; i < remSize.length; i++) {
// I'm looking for the index i, when the condition is true
remSize[i].size == remData.size ? remIndex = i : remIndex = -1;
}
The array contains these "sizes": ["34", "36", "38"...].
remData.size is the "size" I'm looking for (e.g. "36").
I need to return the index i if the size I'm searching for is in the index. Otherwise I need to return -1. Is there a better way to do this?