javascript

# Difference in Gift Values - Free Will - Nonprofit Gifts - Full Stack - 11/15/21

``````// Input:
//
// estateSize - the total value of a person's estate (similar to 'net worth')
// oldGifts - list of existing gifts a person is donating to charity
// newGifts - list of new/updated gifts a person is donating to charity
//
// {
//    nonProfit: string,
//    amount: number,
//    amountType: 'dollar' | 'percent'
// }
//
// Instructions:
//
// 1. Calculate the difference in total value between the new and old gifts in dollars
// New and old gift difference example:
// Expected output: -50
//
// Part 1 expected output: -19500
//
// 2. Return the difference in total value between the new and old gifts by non-profit
//
// Expected output:
// {
//     'Planned Parenthood': 1000,
//     'Doctors Without Borders': -500,
//     'United Way': -50000,
//     'Red Cross': 30000
// }

const estateSize = 1000000;

{
nonProfit: "Planned Parenthood",
amount: 10,
amountType: "percent",
},
{
nonProfit: "Doctors Without Borders",
amount: 1000,
amountType: "dollar",
},
{
nonProfit: "United Way",
amount: 5,
amountType: "percent",
}];

{
nonProfit: "Planned Parenthood",
amount: 10,
amountType: "percent",
},
{
nonProfit: "Planned Parenthood",
amount: 1000,
amountType: "dollar",
},
{
nonProfit: "Doctors Without Borders",
amount: 500,
amountType: "dollar",
},
{
nonProfit: "Red Cross",
amount: 3,
amountType: "percent",
}];

for (let i = 0; i < gifts.length; i++) {
} else {
}
}

}

//todo

}

} else {
return (gift.amount / 100) * estateSize;
}
}

//todo
} else {
}

return nonProfitToDiff;
}, {});

//   if (nonProfitToDiff[oldGift.nonProfit] != null) {
//   } else {
//   }
// }, nonProfitToDiff);