Here's an array I've defined in Typescript:
this.days_in_month = [
[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
[31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
];
My goal is to iterate through this array and for each value, generate a new empty array with a length equal to the value. These arrays will then be added to another array.
For example, if the first value is 31, I would create an empty array with 31 elements and add it to the array of arrays. Then for the next value, let's say 28, I would create a new array with 28 elements and add it to the array so that now it contains both the 31-element array and the 28-element array.
In Python, I would use the range function for this task, but I'm uncertain how to achieve the same result in Typescript.
Here is what I have attempted so far in Typescript:
this.days_in_month.forEach(function(value, index, array) {
console.log(value, index, array);
no_of_days: number = this.days_in_month(value);
let days = new Array<number>(no_of_days);
})