Take a specified weekday, and check if it falls on the remaining days of the current month So like the title says, if we are close to the end of the month, we can check if a given weekday (or array of weekdays) will fall from the current day, to the end of the month. If any of the given days appear, return true, else return false. 

I'm quite inexperienced with JS, and this is my first time using the map function. I think splitting the two functions is ok, although I've seen map used with a nested anonymous function. 

Any feedback on the solution or the use of map would be appreciated. 

// Remember, in the JS date object, months are zero based, days are one based XD
// take a project weekday, and check if it falls on the remaining days of the current month
function check_days_remaining(day) {

  var d = new Date();
  var days_in_month = new Date(d.getYear(), (d.getMonth() + 1), 0).getDate();
  var month_day = d.getDate();
  var month_days_remaining = days_in_month - month_day;

  for(i = 1; i &lt;= month_days_remaining; i++) { 
    var index_date = new Date(d.getYear(), (d.getMonth() + 1), (d.getDate()+i) );
    var index_day = index_date.getDay();
    if(index_day == day) { 
      //console.log("Weekday: " + index_day + " falls on " + index_date);
      return true;
    }
  }

}


function days_remaining(days) {
  remaining = days.map(check_days_remaining);
  // console.log(remaining); // logs an array of true or undefined elements
  return ( remaining.indexOf( true ) &gt; -1 ) ? true : false; // true if at least one project day is remaining in current month
}

var stay_on_month = days_remaining([5,6]); // set whether to stay on current month or display next month
console.log(stay_on_month); // check result
Calculate the accepted weekdays range for today's week once, then check the input array for any value in the range.

function weekdaysBelongToTheRestOfThisMonth(weekdays) {
    var today = new Date();
    var todayDay = today.getDate();
    var todayWeekday = today.getDay();

    var maxMonthDate = new Date(today.getFullYear(), today.getMonth() + 1, 0);
    var maxMonthDay = maxMonthDate.getDate();
    var maxMonthWeekday = maxMonthDate.getDay();
    var maxWeekday = maxMonthDay - todayDay &gt; 7 - todayWeekday ? 7 : maxMonthWeekday;

    return weekdays.some(function(d) { return d &gt;= todayWeekday &amp;&amp; d &lt;= maxWeekday });
}