Published
- 1 min read
js get next weekend
The solution for this is noted below
js get next weekend
Solution
function getNextDayOfWeek(date, dayOfWeek) {
// Code to check that date and dayOfWeek are valid left as an exercise ;)
var resultDate = new Date(date.getTime())
resultDate.setDate(date.getDate() + ((7 + dayOfWeek - date.getDay()) % 7))
return resultDate
}
Try other methods by searching on the site. That is if this doesn’t work