0

I want to check, if the date of a "wh"-Object is NOT a Saturday or Sunday.

this.state.workingHours.map((wh) => {
      if (wh.date.getDay() !== 6 || wh.date.getDay() !== 0) {
        console.log(
          "goes in",
          this.context.dateService.format(wh.date, "EEEE")
        );
      }
    });

In my console output, it looks like: goes in Wednesday goes in Thursday goes in Friday goes in Saturday goes in Sunday goes in Monday ...

Why does the date comparison not work?

der papa
  • 35
  • 5
  • 1
    Because your if statement is always true. Change `||` to `&&` – Andy Ray Feb 26 '23 at 06:54
  • Does this answer your question? [Why does non-equality check of one variable against many values always return true?](https://stackoverflow.com/questions/26337003/why-does-non-equality-check-of-one-variable-against-many-values-always-return-tr) – VLAZ Feb 26 '23 at 07:47

0 Answers0