Heather, great work. I sincerely cannot thank you enough.
Below is the final code that I wrote with javascript. I hope this snippet gets added to the Leaflet documentation.
var lats = [];
var lngs = [];
for (var i = 0; i < markers.length; i++) {
// create a marker here
// add the marker coordinates to the lats and lngs arrays
lats.push(lat[i]);
lngs.push(lng[i]);
// if iteration creates the last marker, then execute setbounds() function, passing variables [map, lats (array), and lngs (array)] to the function
if(i>markercount-2){
setbounds(map, lats, lngs);
}
} // END MAIN FOR EACH MARKER LOOP
function setbounds(map, lats, lngs){
var maxlat = Math.max.apply(Math, lats);
var maxlng = Math.max.apply(Math, lngs);
var minlat = Math.min.apply(Math, lats);
var minlng = Math.min.apply(Math, lngs);
var sw = new L.LatLng(minlat,minlng);
var ne = new L.LatLng(maxlat,maxlng);
var bounds = new L.LatLngBounds(sw, ne);
map.fitBounds(bounds);
}
Many many thanks Heather.