1313// for (let i = -14; i < 12; i = i + 2) {
1414// console.log(i);
1515// }
16-
16+ // for (let i = 20; i < 50 % 3; i = i + 2) {
17+ // console.log(i);
18+ // }
1719
1820/*Exercise #2:
1921Initialize two variables to hold the string “LaunchCode” and the array [1, 5, ‘LC101’, ‘blue’, 42].
@@ -22,18 +24,21 @@ Initialize two variables to hold the string “LaunchCode” and the array [1, 5
2224Construct ``for`` loops to accomplish the following tasks:
2325 a. Print each element of the array to a new line.
2426 b. Print each character of the string - in reverse order - to a new line. */
25- let Name = "LaunchCode "
26- let arr = [ 1 , 5 , 'LC101' , 'blue' , 42 ]
27- let reversed = ""
27+ // let name = "LaunchCode "
28+ // let arr = [1,5,'LC101','blue',42]
29+ // let reversed = ("");
2830// for (let i = 0; i < arr.length; i++) {
2931// console.log(arr[i]);
3032// }
3133
32- for ( let i = 11 ; i < Name . length ; i ++ ) {
33- reversed = Name [ 1 ] + reversed ;
34- console . log ( reversed ) ;
35- }
34+ // for (let i = 0 ; i < name .length; i++) {
35+ // reversed = name[i ] + reversed;
36+ // console.log(reversed);
37+ // }
3638
3739/*Exercise #3:Construct a for loop that sorts the array [2, 3, 13, 18, -5, 38, -10, 11, 0, 104] into two new arrays:
3840 a. One array contains the even numbers, and the other holds the odds.
39- b. Print the arrays to confirm the results. */
41+ b. Print the arrays to confirm the results. */
42+ let array = [ 2 , 3 , 13 , 18 , - 5 , 38 , - 10 , 11 , 0 , 104 ]
43+
44+ for ( i = 0 ; array . lenghth ; ++ i )
0 commit comments