title: How to find the days of the week in JavaScript
body: <p>I am trying to find the weekdays from today to Sunday. Since today is Monday I want to display the dates from Monday till Sunday, but tomorrow, I want my programme works from Tuesday to Sunday.</p>
  <pre><code>dateSets() {
              let firstDayOfWeek = &quot;&quot;;
              let dates = [];
              firstDayOfWeek = new Date();
                  let sunday = new Date();
                  sunday.setDate(sunday.getDate() - sunday.getDay() + 7);
                  const diff = sunday.getDate() - firstDayOfWeek.getDate();
                  dates.push(new Date());
                  for (let i = 0; i &lt; diff; i++) {
                      dates.push(
                          new Date(firstDayOfWeek.setDate(firstDayOfWeek.getDate() + 1))
                      );
                  }
              return dates;
          },
  </code></pre>
  <p>And here is the other function to find the date of the week:</p>
  <pre><code>getDateOfWeek(week, year) {
              let simple = new Date(year, 0, 1 + (week - 1) * 7);
              let dow = simple.getDay();
              let weekStart = simple;
              if (dow &lt;= 4) weekStart.setDate(simple.getDate() - simple.getDay() + 1);
              else weekStart.setDate(simple.getDate() + 8 - simple.getDay());
              return weekStart;
          },
  </code></pre>
  <p>But it doesn't work that I expected, in dataset, only Monday is being displayed but not other dates and I don't understand the reason. If you can help me with this, I would be really glad.
  Thanks...</p>