javascript function return date array for all Sundays in a year
<p>i am writing a function in javascript that will return date array of all sundays.
below you can see my code :</p>

<pre><code>function getDefaultOffDays(year){
var offdays=new Array();
i=0;
for(month=1;month&lt;12;month++)
{
    tdays=new Date(year, month, 0).getDate();

    for(date=1;date&lt;=tdays;date++)
    {
        smonth=(month&lt;10)?"0"+month:month;
        sdate=(date&lt;10)?"0"+date:date;
        dd=year+"-"+smonth+"-"+sdate;

        day=new Date();
        day.setDate(date);
        day.setMonth(month);
        day.setFullYear(year);

        if(day.getDay() == 0 )
             {              
               offdays[i++]=dd;

             }
    }
}

return offdays;
}
</code></pre>

<p>the issue is that the returned array is giving random dates not the only dates for sunday :(
m i missing some thing?</p>
