The snippet below pretty much says it all, but in short I need to distribute a certain amount of months equally over activities. Since there is always a chance to deal with a remainder these should be added to the first month.
const selectedMonth = 5
const project = {
duration: 2, // in months
activities: [{
number: 1,
title: 'game 1'
},
{
number: 2,
title: 'game 2'
},
{
number: 3,
title: 'game 3'
},
]
}
// 1 Add a "plannedInMonth" property to each activity
// 2 Start planning from the selected month and onwards (the month number can be > 12)
// 3 Spread the activities evenly based on the duration
function planActivitiesInMonths() {}
planActivitiesInMonths()
// So this function should, since the remainder of 3 / 2 = 1, return as follows:
activities: [{
number: 1,
title: 'game 1',
plannedInMonth: 5
},
{
number: 2,
title: 'game 2',
plannedInMonth: 5
},
{
number: 3,
title: 'game 3',
plannedInMonth: 6
},
]
// However, it should also work when e.g. 24 activities need to be distributed across 5 months