Skip to content

Instantly share code, notes, and snippets.

@itsanna
Last active August 29, 2015 14:27
Show Gist options
  • Save itsanna/2f10837b5769a7c9af14 to your computer and use it in GitHub Desktop.
Save itsanna/2f10837b5769a7c9af14 to your computer and use it in GitHub Desktop.
var dinnerBills = [
{name:'Otto', bill: 12.45 },
{name:'Jax', bill: 9.55 },
{name:'Chibs', bill: 15.25 },
{name:'Tig', bill: 11.75 }
];
var taxPercent = 8.75;
var tipPercent = 15.00;
function calcEach(eachBill) {
return ((eachBill) +
(eachBill / taxPercent) +
(eachBill / tipPercent)).toPrecision(4);
}
function getTotalBillAmount (eachBill) {
var personalBill = {};
personalBill['name'] = eachBill.name;
personalBill['bill'] = calcEach(eachBill.bill);
return personalBill;
}
var newDinnerBills = dinnerBills.map(getTotalBillAmount);
console.log(newDinnerBills);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment