-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay4.js
More file actions
75 lines (63 loc) · 1.02 KB
/
Copy pathDay4.js
File metadata and controls
75 lines (63 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//Activty 1
for (let index = 1; index <= 10; index++) {
const element = index;
console.log(element);
}
for (let index = 0; index <= 10; index++) {
const element = index;
const prod = 5 * index;
console.log(`5 * ${index}=${prod}`);
}
//Activity 2
let i = 1;
let sum = 0;
while (i <= 10) {
sum += i;
i++;
}
console.log(sum);
let j = 10;
while (j > 0) {
console.log(j);
j--;
}
//Activity 3
let k = 1;
do {
console.log(k);
k++;
} while (k > 6);
//Factorial
let n = 10;
let fact = 1;
do {
fact = fact * n;
n--;
} while (n > 0);
console.log(fact);
//Activity 4
//pattern printing
for (let m = 0; m < 5; m++) {
let row = "";
for (let p = 0; p <= m; p++) {
row += "*";
}
console.log(row);
}
//Activity 5
for (let index = 1; index <= 10; index++) {
const element = index;
if ((element == 5)) {
continue;
} else {
console.log(element);
}
}
for (let index = 1; index <= 10; index++) {
const element = index;
if ((element == 7)) {
break;
} else {
console.log(element);
}
}