We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 44e3e9a commit 385f75bCopy full SHA for 385f75b
25_total.js
@@ -0,0 +1,26 @@
1
+// function , array, condition
2
+
3
+const gas = [10, 10, 10, 10];
4
+const food = [10, 100];
5
6
+function calculateTotal(arr) {
7
+ // loop
8
+ let total = 0;
9
+ for (let i = 0; i < arr.length; i++) {
10
+ // for totally
11
+ total += arr[i];
12
+ }
13
+ if (total > 100) {
14
+ console.log('Total bigger than 40');
15
+ } else {
16
+ console.log('Total smaller then 40');
17
18
+ return total;
19
+}
20
21
+const gasTotal = calculateTotal(gas);
22
+const foodTotal = calculateTotal(food);
23
+console.log({
24
+ gas: gasTotal,
25
+ food: foodTotal,
26
+});
0 commit comments