There was an error while loading. Please reload this page.
1 parent f3a2be9 commit dc89d29Copy full SHA for dc89d29
Javascript_Study_Month/week1/loops.js
@@ -0,0 +1,11 @@
1
+// for loop to find sum of numbers from 1 to 10
2
+
3
+let sum = 0;
4
+// Using a for loop to iterate from 1 to 10
5
+for (let i = 1; i <= 10; i++) {
6
+ // Add the current number to the sum
7
+ sum += i;
8
+ // Output the current number and sum
9
+ console.log("Current number:", i, "Current sum:", sum);
10
+}
11
+console.log("Sum of numbers from 1 to 10 is:", sum); // Output: Sum of numbers from 1 to 10 is: 55
0 commit comments