How to check if date is Monday in JavaScript

1 Answer

0 votes
function isMonday(date = new Date()) {
  	return date.getDay() === 1;
}


console.log(isMonday(new Date('2022-03-9'))); 
console.log(isMonday(new Date('2022-03-7'))); 


  
  
  
  
/*
run:
  
false
true
  
*/

 



answered Mar 10, 2022 by avibootz

Related questions

1 answer 184 views
1 answer 132 views
1 answer 126 views
1 answer 118 views
118 views asked Mar 24, 2022 by avibootz
1 answer 128 views
128 views asked Mar 24, 2022 by avibootz
1 answer 124 views
1 answer 180 views
...