Detail Table - Not looping through records

I have a detail table with a field that indicates what footnotes information needs to print on the back of the page. The footnotes could be within any of the detail records, so:

detail 1 has no footnotes(NNNNNNNNNNNN)
detail 2 has no footnote(NNNNNNNNNNNN)
detail 3 has a footnote(03NNNNNNNNNN)
detail 4 has no footnote(NNNNNNNNNNNN)

My code doesn’t seem to be looping through the detail table correctly to trigger the footnote. For this particular records, detail 3 has a footnote. If I type 3 in my if statement “I” location, the record populates correctly. I have tried this multiple ways with no success. See below:

var footer3;

results.each(function(i){
if (record.tables.G_Fields[i].fields.footnotes.indexOf(“03”) >= 0){
footer3 = loadhtml(“snippets/footer_notes.html”, “#footer_3”);
}else{
footer3 = “”;
}
results.html(footer3);
});

ALSO…

var footer3;

if (record.tables.G_Fields[0].fields.footnotes.indexOf(“03”) >= 0) {
footer3 = loadhtml(“snippets/footer_notes.html”, “#footer_3”);
}else{
footer3 = “”;
}
results.html(footer3);

This has been completed. I fixed with a For Loop.