date = new Date(2015,0,1); cnt = 0; while(date.getFullYear() == 2015){ cnt += ((Math.floor(date.getDate()/10) + date.getDate()%10) == date.getMonth()+1)?1:0; date.setDate(date.getDate()+1) } console.log(cnt);