1👍
✅
I can’t reproduce the steps as it works for me. But instead of using 0 or 1, you can use boolean values true or false.
Maybe if you’re having this issue, it’s because the date format is the wrong one.
It looks like you’re French (according to your comment) and maybe your Date object is set to use MM-DD-YYYY date format instead of our french format being DD-MM-YYYY
Here is my code and it works for me, even in december :
const isWeekend = (date) => {
const day = new Date(date).getDay()
return ( day == 6 || day == 0)
}
// 12-15-2019 --> Sunday 15th December 2019
console.log(isWeekend('12-15-2019')) // returns true
👤Dokt
Source:stackexchange.com