With the following code, I want to push an array inside the weeks array if i is <= to the value of each element in that array.
const weeks = [];
const daysInWeek = [];
numberOfDays = 35;
for (let i = 1; i <= numberOfDays; i ++) {
if (i % 7 === 0){
weeks.push(i)
}
// output [7, 14, 21, 28, 35]
for (logic here...) {
daysInWeek.push([?])
}
}
I would like daysInWeek to look something like this :
[[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15,......], ...]
It is the first time I work with nested loops and I can't really grasp the idea and therefor I am unsure how to use the second loop.
Any help would be greatly appreciated.