- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path25_total.js
More file actions
Latest commit
26 lines (23 loc) · 502 Bytes
/
Copy path25_total.js
File metadata and controls
26 lines (23 loc) · 502 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// function , array, condition
constgas=[10,10,10,10];
constfood=[10,100];
functioncalculateTotal(arr){
// loop
lettotal=0;
for(leti=0;i<arr.length;i++){
// for totally
total+=arr[i];
}
if(total>100){
console.log('Total bigger than 40');
}else{
console.log('Total smaller then 40');
}
returntotal;
}
constgasTotal=calculateTotal(gas);
constfoodTotal=calculateTotal(food);
console.log({
gas: gasTotal,
food: foodTotal,
});