Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const dates = [
- {value: 'Jul 19'},
- {value: 'Aug 19'},
- {value: 'Sep 19'},
- {value: 'Oct 19'},
- {value: 'Nov 19'},
- {value: 'Dec 19'},
- {value: 'Jan 20'},
- ];
- function randomDelta() {
- return Math.floor(Math.random() * Math.floor(10)) * 50;
- }
- function getActualSpent(budget) {
- if (isNaN(budget)) {
- return randomDelta();
- } else {
- return budget + randomDelta();
- }
- }
- const newCampaigns = campaigns.map(c => {
- const {actualSpent} = c;
- const budgets = dates.map(({value, realIndex}, index) => ({
- actualSpent: getActualSpent(actualSpent),
- realIndex: index + 1,
- value,
- }));
- console.log({
- ...c,
- budget: budgets
- });
- return {
- ...c,
- budget: budgets
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment