function addAllTimeZonesListners() {
  allTimeZonesToRender.forEach(function (zone, index) {
    const button = document.getElementById("Add_" + String(index));
    if (button) {
      button.addEventListener("click", function () {
        // becauase datetime cannot be saved in localstorage I
        // only chose to save these fields. With these
        // fields the corresponding dateTime can be found.
        const toLocalStorage = {
          countryCode: zone.countryCode,
          countryName: zone.countryName,
          zoneName: zone.zoneName,
        };
        saveTimeZoneToFavorites(toLocalStorage); // the new favorite timeZone nees to be saved to localstorage
        updateFavoriteTimeZones(); // after an add the favoriteTimeZonesToRender grows
        formatFavoriteTimeZones(); //because favoriteTimeZonesToRender has grown the table has to be rerenderd.
        // addFavoriteTimeZonesListners(); // the rerenderd table needs to have the button listeners added.
      });
    }
  });
}
//listen for timeZone Add events in all timeZones table
listen for timeZone Add events in all timeZones table
listen for timeZone Add events in all timeZones table
function addAllTimeZonesListners() {
  allTimeZonesToRender.forEach(function (zone, index) {
    const button = document.getElementById("Add_" + String(index));
    if (button) {
      button.addEventListener("click", function () {
        const toLocalStorage = {
          countryCode: zone.countryCode,
          countryName: zone.countryName,
          zoneName: zone.zoneName,
        };
        saveTimeZoneToFavorites(toLocalStorage); 
        updateFavoriteTimeZones(); 
        formatFavoriteTimeZones(); 
      });
    }
  });
}
function addAllTimeZonesListners ( ) { allTimeZonesToRender . forEach ( function ( zone , index ) { const button = document . getElementById ( "Add_" + String ( index ) ) ; if ( button ) { button . addEventListener ( "click" , function ( ) { const toLocalStorage = { countryCode : zone . countryCode , countryName : zone . countryName , zoneName : zone . zoneName , } ; saveTimeZoneToFavorites ( toLocalStorage ) ; updateFavoriteTimeZones ( ) ; formatFavoriteTimeZones ( ) ; } ) ; } } ) ; }
listen for timeZone Add events in all timeZones table
listen for timeZone Add events in all timeZones table
// becauase datetime cannot be saved in localstorage I // only chose to save these fields. With these // fields the corresponding dateTime can be found. // the new favorite timeZone nees to be saved to localstorage // after an add the favoriteTimeZonesToRender grows //because favoriteTimeZonesToRender has grown the table has to be rerenderd. // addFavoriteTimeZonesListners(); // the rerenderd table needs to have the button listeners added.