Skip to content

Commit 600e1f7

Browse files
committed
revised exercises
1 parent 2abb7b5 commit 600e1f7

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed
Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
// Experiment with this loop by modifying each of the following: the variable initialization, the boolean condition, and the update expression.
22

3-
for (let i = 0; i < 51; i++) {
4-
console.log(i);
5-
}
3+
for (let i = 0; i < 3; i++) {
4+
console.log(4);
5+
}
6+
7+
let n = 6;
8+
let total = 0;
9+
10+
for (let i = 1; i <= n; i++) {
11+
total += i;
12+
}
13+
14+
console.log(total);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
// create an array variable containing the names
2+
let familyNames = ["Yenny", "Dillan", "Shylea", "Danna", "Jose"];
23

34
// write a for loop that prints each name on a different line
5+
for (let i = 0; i < familyNames.length; i++) {
6+
console.log(familyNames[i]);
7+
}

loops/chapter-examples/while-Loop-Example.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ let i = 0;
33
while (i < 51) {
44
console.log(i);
55
i++;
6-
}
6+
}
7+

loops/exercises/for-Loop-Exercises.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ console.log(reversed);
5151
let evens = [];
5252
let odds = [];
5353

54-
for (let i=0; i < arr1.length; i++) {
54+
for (let i = 0; i < arr1.length; i++) {
5555
if (arr1[i] % 2 == 0) {
5656
evens.push(arr1[i]);
5757
} else {

0 commit comments

Comments
 (0)