Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing "monthDays.innerHTML = days" in for loop #2

Open
austinginn opened this issue Oct 27, 2020 · 1 comment
Open

Missing "monthDays.innerHTML = days" in for loop #2

austinginn opened this issue Oct 27, 2020 · 1 comment

Comments

@austinginn
Copy link

Current:

for (let i = 1; i <= lastDay; i++) {
    if (i === new Date().getDate() && date.getMonth() === new Date().getMonth()) {
      days += `<div class="today">${i}</div>`;
      console.log("found current date: " + i );
    } else {
      console.log("adding day: " + i);
      days += `<div>${i}</div>`;
    }
  }

Corrected:

  for (let i = 1; i <= lastDay; i++) {
    if (i === new Date().getDate() && date.getMonth() === new Date().getMonth()) {
      days += `<div class="today">${i}</div>`;
      console.log("found current date: " + i );
    } else {
      console.log("adding day: " + i);
      days += `<div>${i}</div>`;
    }
    monthDays.innerHTML = days;
  }
@AdehenryOmoOba
Copy link

this fixed the issue of February reaching 31.....but when you click on "next" icon to change from december 2020 to january 2021, the year does not change, it stays at 2020 instead of changing to 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants