const addMissingZeros = date => (/^\d$/.test(date) ? `0${date}` : date);


const formatter = (date, readable) => {
  const year = date.getFullYear();
  const month = addMissingZeros(date.getMonth() + 1);
  const day = addMissingZeros(date.getDate());

  return readable ? `${year}-${month}-${day}` : `${year}${month}${day}`;
};


function getPalindromeDates(start, palindromesToShow = 15) {
  let date = start || new Date(2020, 3, 2);

  for (
    let i = 0;
    i < palindromesToShow;
    date = new Date(date.setDate(date.getDate() + 1))
  ) {
    const formattedDate = formatter(date);
    if (formattedDate === formattedDate.split("").reverse().join("")) {
      i++;
      console.log(formatter(date, true));
    }
  }
}

getPalindromeDates();