We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 955af4c commit 8682266Copy full SHA for 8682266
1 file changed
Loops/forinof.js
@@ -0,0 +1,24 @@
1
+
2
+// for..in loop
3
+// The for..in loop is used to iterate over the properties of an object.
4
+const person = {
5
+ name: "John",
6
+ age: 30,
7
+ city: "New York"
8
+};
9
10
+for (let i in person) {
11
+ console.log(person[i]);
12
+}
13
14
15
+// for..of loop
16
+// The for..of loop is used to iterate over iterable objects like arrays, strings, etc.
17
+var numbers = [1, 2, 3];
18
+var sum = 0;
19
+for (let i of numbers) {
20
+ //console.log();
21
+ sum += i;
22
23
24
+console.log("Sum is " + sum);
0 commit comments