I have an original two-dimensional array which represents the 100% version budget per year, looking like:
budget = [['2001-01-01', 100], ['2001-01-02', 110], ... , ['2001-12-31', 140]]
Now I need to create subarrays of the budget for projects. For example:
project1 = [['2001-01-01', 10], ['2001-01-02', 11]]
meaning, that it goes for 2 days and uses 10% of the available budget.
I create the project arrays by the following function:
project1 = [[]];
project1 = new_project(budget, 0, 1, 0.1);
function new_project(origin, start, end, factor) {
var result = [[]];
result = origin.slice(parseInt(start), parseInt(end)).map(function (item) {
return [item[0], parseInt(item[1]) * factor]
});
return result;
}
Problem
How can I decrease my budget array now by the values of my created project? I need to modifiy budget on the fly by calling new_project in order to get:
budget = [['2001-01-01', 90], ['2001-01-02', 99],..., ['2001-12-31', 140]]