Skip to content

Commit 565f960

Browse files
committed
for Loops
1 parent 0466d0c commit 565f960

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

loops/exercises/for-Loop-Exercises.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
/*Exercise #1: Construct for loops that accomplish the following tasks:
22
a. Print the numbers 0 - 20, one number per line.
3+
4+
35
b. Print only the ODD values from 3 - 29, one number per line.
46
c. Print the EVEN numbers 12 to -14 in descending order, one number per line.
57
d. Challenge - Print the numbers 50 - 20 in descending order, but only if the numbers are multiples of 3. (Your code should work even if you replace 50 or 20 with other numbers). */
68

9+
for (let i = 0; i < 21; i++) {
10+
console.log(i)
11+
}
12+
13+
for (let i = -14; i < 12; i = i + 3) {
14+
console.log(i);
715

16+
}
817

918

19+
let words = ['1','5','LC101','blue','42']
20+
21+
for (let i=0; i<words.length; i++) {
22+
console.log(words[i])
23+
}
1024
/*Exercise #2:
1125
Initialize two variables to hold the string “LaunchCode” and the array [1, 5, ‘LC101’, ‘blue’, 42].
1226
1327
28+
29+
30+
31+
32+
1433
Construct ``for`` loops to accomplish the following tasks:
1534
a. Print each element of the array to a new line.
1635
b. Print each character of the string - in reverse order - to a new line. */

0 commit comments

Comments
 (0)