Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var bills = {
- billAmounts: [124, 48, 268, 180, 42],
- allTips: [],
- totalPaid: [],
- calcTip: function () {
- for (var i = 0; i < this.billAmounts.length; i++) { //runs through each interger in array
- if (this.billAmounts < 50) {
- this.allTips.push(this.billAmounts[i] * 0.20);
- } else if(this.billAmounts > 50 < 200) {
- this.allTips.push(this.billAmounts[i] * 0.15);
- }else{
- this.allTips.push(this.billAmounts[i] * 0.15);
- }
- }
- this.totalPaid.push(this.billAmounts[0] + this.allTips[0])
- this.totalPaid.push(this.billAmounts[1] + this.allTips[1])
- this.totalPaid.push(this.billAmounts[2] + this.allTips[2]
- this.totalPaid.push(this.billAmounts[3] + this.allTips[3])
- this.totalPaid.push(this.billAmounts[4] + this.allTips[4])
- for (var i = 0; i < this.billAmounts.length;i++){
- return this.totalPaid.push(this.billAmounts[i] + this.allTips[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement