programming-examples/js/Date/Write a JavaScript function to test whether a date is a weekend..js
2019-11-15 12:59:38 +01:00

12 lines
322 B
JavaScript

var is_weekend = function(date1){
var dt = new Date(date1);
if(dt.getDay() == 6 || dt.getDay() == 0)
{
return "weekend";
}
}
console.log(is_weekend('Nov 15, 2014'));
console.log(is_weekend('Nov 16, 2014'));
console.log(is_weekend('Nov 17, 2014'));