I'm trying to fill all array position from `firstDay(6)` to `numberOfDaysInAMonth(29)` with values between [`1` and `numberOfDaysInAMonth(29)`]. and rest all positions with `-1`

currently my value from `firstDay` starting with 6, it should be from `1` to `numberOfDaysInAMonth`

I'm expecting output something like below one:

```
[-1,-1,-1,-1,-1,-1,1....29,-1,-1,-1,-1,-1,-1,-1] // 6(-1) and at end 7(-1)

```

as opposed to:

```
[-1,-1,-1,-1,-1,-1,6....28,-1,-1,-1,-1,-1,-1,-1]

```

i'm doing this to construct a calendar for any given month and year.

**My Expectation:** Best and easy way or algorithm

**Question:** you can see date is starting at correct spot `6` with wrong value `6`(it should be `1` till `29`).

**For better view i have created codepen**:<https://codepen.io/eabangalore/pen/ExVgrjB> (you can see date is starting from correct spot but with wrong value `6` it should be `1` till `29`)

```js
var allDates = Array(42).fill(-1,0);

var firstDay = (new Date('2020', 1)).getDay(); //6, from where our actual dates will start

var numberOfDaysInAMonth = 32 - new Date(2020, 1, 32).getDate(); //feburary

console.log(numberOfDaysInAMonth); //it should fill till numberOfDaysInAMonth

for(var i = firstDay; i < numberOfDaysInAMonth; i++ ){
    allDates[i] = i;
}

console.log(allDates);

/* 
 **   Display code below
 **
*/

//then i will display them like below
var datetemplate = '', finalTableTemplate = '';
for(var i = 1; i <= allDates.length; i++){
   var notAvailableDateClass = '';
   if(allDates[i] == -1 || allDates[i] == undefined)
          notAvailableDateClass = 'disabled';
     datetemplate += '<span class="'+notAvailableDateClass+'">'+allDates[i]+'</span>';
   if((i % 7) == 0 ){ finalTableTemplate += '<div>'+datetemplate+'</div>'; datetemplate = '';}
}
document.querySelector('#dates').innerHTML = finalTableTemplate;
```

```css
span{
    display: inline-block;
    width: 38px;
    height: 29px;
    background: red;
    color: #fff;
    margin: 1px;
    text-align: center;
    line-height: 30px;
}

span.disabled {
    background: #ccc;
    color: #000;
}
```

```html
<div id="dates"></div>
```