moment get week from date code example

Example 1: moment get weekday name

var m = moment().day(); // gives 4 for thursday, then you can do a switch

Example 2: moment get list of dates by week number

var dateformat = "YYYY/MM/DD";
function getWeekDaysByWeekNumber(weeknumber)
{
    var date = moment().isoWeek(weeknumber||1).startOf("week"), weeklength=7, result=[];
    while(weeklength--)
    {
        result.push(date.format(dateformat));
        date.add(1,"day")
    }
    return result;
}

console.log(getWeekDaysByWeekNumber())
console.log(getWeekDaysByWeekNumber(2))
console.log(getWeekDaysByWeekNumber(25))