Last active
August 29, 2015 14:27
-
-
Save itsanna/2f10837b5769a7c9af14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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