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 276 views
1 answer 226 views
1 answer 208 views
1 answer 206 views
206 views asked Mar 24, 2022 by avibootz
1 answer 205 views
205 views asked Mar 24, 2022 by avibootz
1 answer 216 views
1 answer 275 views
...