Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

Commit 06d9bdc

Browse files
committed
feat: Challenge 8 of JS Fundamentals Done
1 parent 5969272 commit 06d9bdc

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const calcTip = function (bill) {
2+
return bill >= 50 && bill <= 300 ? bill * 0.15 : bill * 0.2;
3+
}
4+
5+
const calcAverage = function(arr){
6+
let sum =0;
7+
let n = arr.length
8+
for(let i=0;i<n;i++){
9+
sum+=arr[i];
10+
}
11+
return sum/n;
12+
}
13+
14+
let bills =[22,295,176,440,37,105,10,1100,86,52];
15+
let tips=[];
16+
let totals=[];
17+
18+
for(let i=0;i<bills.length;i++){
19+
tips[i]=calcTip(bills[i]);
20+
totals[i]=bills[i]+tips[i];
21+
}
22+
23+
calcAverage(totals);

0 commit comments

Comments
 (0)