Looping function issue

ok my problem is that i want this code to look to see if “race* includes the value of query[t]” and to apply the lower code if it is but if it’s not then to increment t by 1 and to check again. until it finds a match.

if (race*.indexOf(querys[t]) != -1) {
whichRace = sportEvent.childNodes*.childNodes[0].childNodes;
raceName = sportEvent.childNodes*.attributes.name;
raceLink = sportEvent.childNodes*.childNodes[0].attributes.couponLink;
raceBox.race.text = raceName;
}
else{t++};

Any help would be very appreciated

Thanks