AnsweredAssumed Answered

Loop Through Array

Question asked by john_richardson_1969 on Sep 18, 2018
Latest reply on Sep 19, 2018 by khutchins-esristaff

I am trying to figure out what is wrong with the following code ... I have an array of addresses that I will be feeding into a search widget on a map ... right now, I am trying to loop through the array and display all addresses in an alert window ... can anyone help?

-----------------------------------------------------------------------------------------------------------------------

var addressArray = [
[0, "500 W. 22nd St."],
[1, "500 W. 38th St."],
[2, "501 College Dr."],
[3, "505 Madison Ave."],
[4, "501 S. Scatterfield Rd."],
[5, "501 Sycamore St."],
[6, "501 W. 10th St."],
[7, "501 W. 22nd St."],
[8, "501 W. 2nd St."],
[9, "501 W. 34th St."],
[10, "501 W. 37th St."],
[11, "501 W. 8th St."],
[12, "501 Welcome Way"],
[13, "501 Woodmere Dr."],
[14, "502 Marine Dr."],
[15, "502 Blackfoot Dr."],
[16, "502 S. Buckingham Ct."],
[17, "502 E. 8th St."],
[18, "502 Jackson St."],
[19, "502 W. 12th St."],
[20, "502 W. 33rd St."],
[21, "502 W. 34th St."],
[22, "502 W. 7th St."],
[23, "502 Welcome Way"],
[24, "502 Woodmere Dr."],
[25, "503 S. Buckingham Ct."],
[26, "503 Central Ave."],
[27, "503 Country Club Ln."],
[28, "503 E. 38th St."],
[29, "503 Federal Dr."],
[30, "503 Henry St."],
[31, "503 Park Ave."],
[32, "503 Ruddle Ave."],
[33, "503 Coventry Dr."],
[34, "503 W. 19th St."],
[35, "503 W. 33rd St."],
[36, "503 W. 34th St."],
[37, "503 W. 37th St."],
[38, "503 W. 3rd St."],
[39, "503 W. 4th St."],
[40, "503 W. 53rd St."],
[41, "503 W. 5th St."],
[42, "504 Welcome Way"],
[43, "504 Park Ave."],
[44, "504 Andover Rd."],
[45, "504 E. 38th St."],
[46, "504 E. 49th St."],
[47, "504 Federal Dr."],
[48, "504 Gene Gustin Way"],
[49, "504 N. Buckingham Ct."],
[50, "504 Ruddle Ave."],
[51, "504 W. 10th St."],
[52, "504 W. 11th St."],
[53, "504 W. 17th St."],
[54, "504 W. 29th St."],
[55, "504 W. 34th St."],
[56, "504 W. 3rd St."],
[57, "504 W. 5th St."],
[58, "504 W. 7th St."],
[59, "504 W. 9th St."],
[60, "503 Welcome Way"],
[61, "505 Blackfoot Dr."],
[62, "505 Central Ave."],
[63, "505 E. 21st St."],
[64, "505 E. 23rd St."],
[65, "505 W. 29th St."],
[66, "505 E. 49th St."],
[67, "505 E. 8th St."],
[68, "505 Lonsvale Dr."],
[69, "509 Madison Ave."],
[70, "505 Milton Ave."],
[71, "501 N. Buckingham Ct."],
[72, "505 Rangeline Rd."],
[73, "505 W. 19th St."],
[74, "505 W. 21st St."],
[75, "505 W. 22nd St."],
[76, "505 W. 9th St."],
[77, "517 Welcome Way"],
[78, "506 Milton Ave."],
[79, "506 Blackfoot Dr."],
[80, "506 E. 5th St."],
[81, "506 Hawthorne Ave."],
[82, "506 Marine Dr."],
[83, "506 Coventry Dr."],
[84, "506 W. 12th St."],
[85, "506 W. 2nd St."],
[86, "506 W. 33rd St."],
[87, "506 W. 38th St."],
[88, "506 W. 4th St."],
[89, "506 Wedgewood Dr."],
[90, "518 Welcome Way"],
[91, "507 E. 38th St."],
[92, "507 Central Ave."],
[93, "507 Chester St."],
[94, "507 Cottage Ave."],
[95, "507 Country Club Ln."],
[96, "507 Davis Dr."],
[97, "507 E. 29th St."],
[98, "507 Hawthorne Ave."],
[99, "507 Lennox St."],
[100, "507 Dr. Martin Luther King Jr. Blvd."],
[101, "507 Park Ave."],
[102, "507 Ruddle Ave."],
[103, "507 W. 10th St."],
[104, "507 W. 33rd St."],
[105, "507 W. 37th St."],
[106, "507 W. 3rd St."],
[107, "507 W. 4th St."],
[108, "507 W. 60th St."],
[109, "507 W. 9th St."],
[110, "516 Welcome Way"],
[111, "508 Andover Rd."],
[112, "508 Central Ave."]
];

var k;

$(document).ready(function() {
$('#schoolPic').click(function() {
for (k = 0; k < addressArray.length; k++) {
alert(addressArray[k][1]);
}
});
});

Outcomes