0

I want to call the wunderground api for each date in an array. Then loop through the results and build an object. The first loop is working correctly (I think), but the second one only runs for the first observation out of 23.

var dateArray = ["2018-03-05","2018-03-04","2018-03-03"]
dateArray.every(currentDate => {
    window.o[currentDate] = {}
    var url = "http://api.wunderground.com/api/<mykey>/history_" + currentDate.replace('-','','g') + "/q/FL/Leesburg.json"
    $.ajax({
        url:url,
        success: function(r){
            var wundDateS = r.history.observations[0].date


////// This should be running 23 times per date, but only runs once per date /////
            r.history.observations.every(ob => {
                var wundDateO = new Date(wundDateS.year,wundDateS.mon-1,wundDateS.mday,wundDateS.hour,wundDateS.min)
                var ob2 = ob
                delete ob2.date
                delete ob2.utcdate
                var wundTimeF = getTimeFormatted(wundDateO) // custom function
                window.o[currentDate][wundTimeF] = {}
                window.o[currentDate][wundTimeF] = ob2
                return true
            })


        }
    })
    return true
})

And here's an example of a response from wunderground:

{"response":{"version":"0.1","termsofService":"http://www.wunderground.com/weather/api/d/terms.html","features":{"history":1}},"history":{"date":{"pretty":"March 6, 2018","year":"2018","mon":"03","mday":"06","hour":"12","min":"00","tzname":"America/New_York"},"utcdate":{"pretty":"March 6, 2018","year":"2018","mon":"03","mday":"06","hour":"17","min":"00","tzname":"UTC"},"observations":[{"date":{"pretty":"12:53 AM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"00","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"5:53 AM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"05","min":"53","tzname":"UTC"},"tempm":"12.2","tempi":"54.0","dewptm":"8.3","dewpti":"46.9","hum":"77","wspdm":"0.0","wspdi":"0.0","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"0","wdire":"North","vism":"16.1","visi":"10.0","pressurem":"1017.7","pressurei":"30.06","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 060553Z AUTO 00000KT 10SM CLR 12/08 A3006 RMK AO2 SLP177 T01220083 10194 20122 58007"},{"date":{"pretty":"1:53 AM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"01","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"6:53 AM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"06","min":"53","tzname":"UTC"},"tempm":"12.8","tempi":"55.0","dewptm":"7.8","dewpti":"46.0","hum":"72","wspdm":"0.0","wspdi":"0.0","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"0","wdire":"North","vism":"16.1","visi":"10.0","pressurem":"1017.2","pressurei":"30.04","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 060653Z AUTO 00000KT 10SM CLR 13/08 A3004 RMK AO2 SLP172 T01280078"},{"date":{"pretty":"2:53 AM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"02","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"7:53 AM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"07","min":"53","tzname":"UTC"},"tempm":"11.7","tempi":"53.1","dewptm":"8.3","dewpti":"46.9","hum":"80","wspdm":"0.0","wspdi":"0.0","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"0","wdire":"North","vism":"16.1","visi":"10.0","pressurem":"1016.6","pressurei":"30.02","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 060753Z AUTO 00000KT 10SM CLR 12/08 A3003 RMK AO2 SLP166 T01170083"},{"date":{"pretty":"3:53 AM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"03","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"8:53 AM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"08","min":"53","tzname":"UTC"},"tempm":"11.1","tempi":"52.0","dewptm":"9.4","dewpti":"48.9","hum":"89","wspdm":"0.0","wspdi":"0.0","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"0","wdire":"North","vism":"16.1","visi":"10.0","pressurem":"1016.0","pressurei":"30.01","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 060853Z AUTO 00000KT 10SM CLR 11/09 A3001 RMK AO2 SLP160 T01110094 58016"},{"date":{"pretty":"4:53 AM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"04","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"9:53 AM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"09","min":"53","tzname":"UTC"},"tempm":"12.2","tempi":"54.0","dewptm":"10.0","dewpti":"50.0","hum":"86","wspdm":"0.0","wspdi":"0.0","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"0","wdire":"North","vism":"16.1","visi":"10.0","pressurem":"1016.1","pressurei":"30.01","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 060953Z AUTO 00000KT 10SM CLR 12/10 A3001 RMK AO2 SLP161 T01220100"},{"date":{"pretty":"5:53 AM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"05","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"10:53 AM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"10","min":"53","tzname":"UTC"},"tempm":"12.2","tempi":"54.0","dewptm":"10.6","dewpti":"51.1","hum":"90","wspdm":"0.0","wspdi":"0.0","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"0","wdire":"North","vism":"16.1","visi":"10.0","pressurem":"1016.0","pressurei":"30.01","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 061053Z AUTO 00000KT 10SM CLR 12/11 A3001 RMK AO2 SLP160 T01220106"},{"date":{"pretty":"6:53 AM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"06","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"11:53 AM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"11","min":"53","tzname":"UTC"},"tempm":"13.9","tempi":"57.0","dewptm":"11.7","dewpti":"53.1","hum":"87","wspdm":"11.1","wspdi":"6.9","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"140","wdire":"SE","vism":"16.1","visi":"10.0","pressurem":"1016.5","pressurei":"30.02","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 061153Z 14006KT 10SM CLR 14/12 A3002 RMK AO2 SLP165 T01390117 10144 20106 53005"},{"date":{"pretty":"7:53 AM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"07","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"12:53 PM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"12","min":"53","tzname":"UTC"},"tempm":"15.6","tempi":"60.1","dewptm":"13.3","dewpti":"55.9","hum":"86","wspdm":"9.3","wspdi":"5.8","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"150","wdire":"SSE","vism":"16.1","visi":"10.0","pressurem":"1016.6","pressurei":"30.02","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 061253Z 15005KT 10SM CLR 16/13 A3002 RMK AO2 SLP166 T01560133"},{"date":{"pretty":"8:53 AM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"08","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"1:53 PM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"13","min":"53","tzname":"UTC"},"tempm":"17.2","tempi":"63.0","dewptm":"12.2","dewpti":"54.0","hum":"72","wspdm":"7.4","wspdi":"4.6","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"210","wdire":"SSW","vism":"16.1","visi":"10.0","pressurem":"1017.0","pressurei":"30.04","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 061353Z 21004KT 10SM CLR 17/12 A3004 RMK AO2 SLP170 T01720122"},{"date":{"pretty":"9:53 AM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"09","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"2:53 PM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"14","min":"53","tzname":"UTC"},"tempm":"18.9","tempi":"66.0","dewptm":"12.8","dewpti":"55.0","hum":"68","wspdm":"9.3","wspdi":"5.8","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"230","wdire":"SW","vism":"16.1","visi":"10.0","pressurem":"1017.2","pressurei":"30.04","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 061453Z 23005KT 10SM CLR 19/13 A3004 RMK AO2 SLP172 T01890128 53006"},{"date":{"pretty":"10:53 AM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"10","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"3:53 PM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"15","min":"53","tzname":"UTC"},"tempm":"21.7","tempi":"71.1","dewptm":"9.4","dewpti":"48.9","hum":"45","wspdm":"13.0","wspdi":"8.1","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"210","wdire":"SSW","vism":"16.1","visi":"10.0","pressurem":"1016.9","pressurei":"30.03","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 061553Z 21007KT 10SM CLR 22/09 A3003 RMK AO2 SLP169 T02170094"},{"date":{"pretty":"11:53 AM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"11","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"4:53 PM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"16","min":"53","tzname":"UTC"},"tempm":"23.9","tempi":"75.0","dewptm":"6.7","dewpti":"44.1","hum":"33","wspdm":"14.8","wspdi":"9.2","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"200","wdire":"SSW","vism":"16.1","visi":"10.0","pressurem":"1016.5","pressurei":"30.02","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 061653Z 20008KT 10SM CLR 24/07 A3002 RMK AO2 SLP165 T02390067"},{"date":{"pretty":"12:53 PM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"12","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"5:53 PM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"17","min":"53","tzname":"UTC"},"tempm":"25.0","tempi":"77.0","dewptm":"5.6","dewpti":"42.1","hum":"29","wspdm":"13.0","wspdi":"8.1","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"220","wdire":"SW","vism":"16.1","visi":"10.0","pressurem":"1015.5","pressurei":"29.99","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 061753Z 22007KT 10SM CLR 25/06 A2999 RMK AO2 SLP155 T02500056 10250 20139 58017"},{"date":{"pretty":"1:53 PM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"13","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"6:53 PM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"18","min":"53","tzname":"UTC"},"tempm":"25.6","tempi":"78.1","dewptm":"1.7","dewpti":"35.1","hum":"21","wspdm":"18.5","wspdi":"11.5","wgustm":"35.2","wgusti":"21.9","wdird":"210","wdire":"SSW","vism":"16.1","visi":"10.0","pressurem":"1014.7","pressurei":"29.97","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 061853Z 21010G19KT 10SM CLR 26/02 A2997 RMK AO2 SLP147 T02560017"},{"date":{"pretty":"2:53 PM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"14","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"7:53 PM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"19","min":"53","tzname":"UTC"},"tempm":"25.6","tempi":"78.1","dewptm":"2.2","dewpti":"36.0","hum":"22","wspdm":"18.5","wspdi":"11.5","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"240","wdire":"WSW","vism":"16.1","visi":"10.0","pressurem":"1014.1","pressurei":"29.95","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 061953Z 24010KT 10SM CLR 26/02 A2995 RMK AO2 SLP141 T02560022"},{"date":{"pretty":"3:53 PM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"15","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"8:53 PM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"20","min":"53","tzname":"UTC"},"tempm":"26.1","tempi":"79.0","dewptm":"3.3","dewpti":"37.9","hum":"23","wspdm":"13.0","wspdi":"8.1","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"210","wdire":"SSW","vism":"16.1","visi":"10.0","pressurem":"1013.4","pressurei":"29.93","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Clear","icon":"clear","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 062053Z AUTO 21007KT 10SM CLR 26/03 A2993 RMK AO2 SLP134 T02610033 56021"},{"date":{"pretty":"4:53 PM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"16","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"9:53 PM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"21","min":"53","tzname":"UTC"},"tempm":"25.6","tempi":"78.1","dewptm":"6.7","dewpti":"44.1","hum":"30","wspdm":"13.0","wspdi":"8.1","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"200","wdire":"SSW","vism":"16.1","visi":"10.0","pressurem":"1013.4","pressurei":"29.93","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Scattered Clouds","icon":"partlycloudy","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 062153Z AUTO 20007KT 10SM SCT070 26/07 A2993 RMK AO2 SLP134 T02560067"},{"date":{"pretty":"5:53 PM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"17","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"10:53 PM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"22","min":"53","tzname":"UTC"},"tempm":"24.4","tempi":"75.9","dewptm":"13.3","dewpti":"55.9","hum":"50","wspdm":"13.0","wspdi":"8.1","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"260","wdire":"West","vism":"16.1","visi":"10.0","pressurem":"1013.2","pressurei":"29.92","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Mostly Cloudy","icon":"mostlycloudy","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 062253Z AUTO 26007KT 10SM SCT065 BKN080 24/13 A2992 RMK AO2 SLP132 T02440133"},{"date":{"pretty":"6:53 PM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"18","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"11:53 PM GMT on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"23","min":"53","tzname":"UTC"},"tempm":"23.3","tempi":"73.9","dewptm":"13.9","dewpti":"57.0","hum":"55","wspdm":"18.5","wspdi":"11.5","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"230","wdire":"SW","vism":"16.1","visi":"10.0","pressurem":"1013.5","pressurei":"29.93","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Overcast","icon":"cloudy","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 062353Z AUTO 23010KT 10SM OVC055 23/14 A2993 RMK AO2 SLP135 T02330139 10267 20233 53001"},{"date":{"pretty":"7:53 PM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"19","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"12:53 AM GMT on March 07, 2018","year":"2018","mon":"03","mday":"07","hour":"00","min":"53","tzname":"UTC"},"tempm":"22.8","tempi":"73.0","dewptm":"14.4","dewpti":"57.9","hum":"59","wspdm":"13.0","wspdi":"8.1","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"220","wdire":"SW","vism":"16.1","visi":"10.0","pressurem":"1013.7","pressurei":"29.94","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Overcast","icon":"cloudy","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 070053Z AUTO 22007KT 10SM FEW046 BKN055 OVC070 23/14 A2994 RMK AO2 SLP137 T02280144"},{"date":{"pretty":"8:53 PM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"20","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"1:53 AM GMT on March 07, 2018","year":"2018","mon":"03","mday":"07","hour":"01","min":"53","tzname":"UTC"},"tempm":"21.7","tempi":"71.1","dewptm":"13.9","dewpti":"57.0","hum":"61","wspdm":"14.8","wspdi":"9.2","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"210","wdire":"SSW","vism":"16.1","visi":"10.0","pressurem":"1013.5","pressurei":"29.93","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Overcast","icon":"cloudy","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 070153Z AUTO 21008KT 10SM BKN100 OVC120 22/14 A2993 RMK AO2 SLP135 T02170139"},{"date":{"pretty":"9:53 PM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"21","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"2:53 AM GMT on March 07, 2018","year":"2018","mon":"03","mday":"07","hour":"02","min":"53","tzname":"UTC"},"tempm":"21.7","tempi":"71.1","dewptm":"13.3","dewpti":"55.9","hum":"59","wspdm":"18.5","wspdi":"11.5","wgustm":"-9999.0","wgusti":"-9999.0","wdird":"210","wdire":"SSW","vism":"16.1","visi":"10.0","pressurem":"1013.2","pressurei":"29.92","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Overcast","icon":"cloudy","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 070253Z AUTO 21010KT 10SM BKN090 OVC120 22/13 A2993 RMK AO2 SLP132 T02170133 58003"},{"date":{"pretty":"10:53 PM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"22","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"3:53 AM GMT on March 07, 2018","year":"2018","mon":"03","mday":"07","hour":"03","min":"53","tzname":"UTC"},"tempm":"20.6","tempi":"69.1","dewptm":"15.0","dewpti":"59.0","hum":"70","wspdm":"27.8","wspdi":"17.3","wgustm":"40.7","wgusti":"25.3","wdird":"210","wdire":"SSW","vism":"16.1","visi":"10.0","pressurem":"1013.2","pressurei":"29.92","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"-9999.00","precipi":"-9999.00","conds":"Overcast","icon":"cloudy","fog":"0","rain":"0","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 070353Z AUTO 21015G22KT 10SM OVC110 21/15 A2992 RMK AO2 SLP132 T02060150"},{"date":{"pretty":"11:53 PM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"23","min":"53","tzname":"America/New_York"},"utcdate":{"pretty":"4:53 AM GMT on March 07, 2018","year":"2018","mon":"03","mday":"07","hour":"04","min":"53","tzname":"UTC"},"tempm":"18.3","tempi":"64.9","dewptm":"17.2","dewpti":"63.0","hum":"93","wspdm":"24.1","wspdi":"15.0","wgustm":"38.9","wgusti":"24.2","wdird":"210","wdire":"SSW","vism":"6.4","visi":"4.0","pressurem":"1014.1","pressurei":"29.95","windchillm":"-999","windchilli":"-999","heatindexm":"-9999","heatindexi":"-9999","precipm":"2.8","precipi":"0.11","conds":"Heavy Rain","icon":"rain","fog":"0","rain":"1","snow":"0","hail":"0","thunder":"0","tornado":"0","metar":"METAR KLEE 070453Z AUTO 21013G21KT 4SM +RA BR FEW050 SCT060 OVC100 18/17 A2995 RMK AO2 RAB03 SLP141 P0011 T01830172 402670106"}],"dailysummary":[{"date":{"pretty":"12:00 PM EST on March 06, 2018","year":"2018","mon":"03","mday":"06","hour":"12","min":"00","tzname":"America/New_York"},"fog":"0","rain":"1","snow":"0","snowfallm":"0.00","snowfalli":"0.00","monthtodatesnowfallm":"","monthtodatesnowfalli":"","since1julsnowfallm":"","since1julsnowfalli":"","snowdepthm":"","snowdepthi":"","hail":"0","thunder":"0","tornado":"0","meantempm":"19","meantempi":"66","meandewptm":"10","meandewpti":"50","meanpressurem":"1015","meanpressurei":"29.98","meanwindspdm":"8","meanwindspdi":"5","meanwdire":"","meanwdird":"211","meanvism":"16","meanvisi":"10","humidity":"","maxtempm":"26","maxtempi":"79","mintempm":"11","mintempi":"52","maxhumidity":"93","minhumidity":"21","maxdewptm":"17","maxdewpti":"63","mindewptm":"2","mindewpti":"35","maxpressurem":"1018","maxpressurei":"30.06","minpressurem":"1013","minpressurei":"29.92","maxwspdm":"27","maxwspdi":"17","minwspdm":"0","minwspdi":"0","maxvism":"16","maxvisi":"10","minvism":"6","minvisi":"4","gdegreedays":"16","heatingdegreedays":"0","coolingdegreedays":"0","precipm":"2.79","precipi":"0.11","precipsource":"","heatingdegreedaysnormal":"","monthtodateheatingdegreedays":"","monthtodateheatingdegreedaysnormal":"","since1sepheatingdegreedays":"","since1sepheatingdegreedaysnormal":"","since1julheatingdegreedays":"","since1julheatingdegreedaysnormal":"","coolingdegreedaysnormal":"","monthtodatecoolingdegreedays":"","monthtodatecoolingdegreedaysnormal":"","since1sepcoolingdegreedays":"","since1sepcoolingdegreedaysnormal":"","since1jancoolingdegreedays":"","since1jancoolingdegreedaysnormal":""}]}}

This should be producing 3 window.o[<date>] objects with 23 objects inside, however each date only has one observation, meaning the loop is running only once, and I can't figure out why.

Travis Heeter
  • 13,002
  • 13
  • 87
  • 129
  • 2
    If you `return` anything in a loop, that **ends** the loop. – connexo Mar 08 '18 at 17:52
  • And what is this weirdness? `var ob2 = ob delete ob2.date delete ob2.utcdate var wundTimeF = getTimeFormatted(wundDateO) // custom function window.o[currentDate][wundTimeF] = {} window.o[currentDate][wundTimeF] = ob2` why not `var wundTimeF = getTimeFormatted(wundDateO); delete ob2.date; delete ob2.utcdate; window.o[currentDate][wundTimeF] = ob2;` since you are not making a copy of the object – mplungjan Mar 08 '18 at 18:00
  • @connexo `Array::every` will keep going as long as the inner function returns something truthy (and there are more elements to process). `true` is certainly truthy, so that's not the problem. – Paul Roub Mar 08 '18 at 18:12
  • @connexo if you don't `return true` for an `every` loop, then only runs once. But I tested it without the `return true` in the inner loop, and sure enough it only runs once. How can I get around that? – Travis Heeter Mar 08 '18 at 18:12
  • 1
    You are setting `wundDateS` exactly once per date. Therefore you have only one `wundDateO` and one `wundTimeF` for each date. So every time you set `window.o[currentDate][wundTimeF]` you're overwriting anything else you had set for that date. Either get the date for each `ob` individually, or set `window.o[currentDate][wundTimeF] = []` once per date, then `push()` `ob2` onto it each time through the inner loop. – Paul Roub Mar 08 '18 at 18:16
  • @PaulRoub Good Call, I'll try bringing the `wundDateS` def inside the loop. Thanks! Edit: Yup, totally worked! – Travis Heeter Mar 08 '18 at 18:18

0 Answers0