Alerting on the last iteration of a Loop

Hi So ive read threw a whole bunch of the questions in regards to this.. Most of them throw off my data or I just cant get them to actually proc on the last iteration

for(const[m, value] of datesLess) {
          console.log("Logging M:" + m);
            if(startD == m || endD == m){
              if (m === datesLess.length - 1) {
                    alert("The following Bookings are taken:"+takendates.join("\n"));

In essence im trying to display the alert on the last iteration of the loop so the user can see which dates are incorrect as to just displaying a popup with no details

55 thoughts on “Alerting on the last iteration of a Loop”

Leave a Comment