-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDay4.js
81 lines (72 loc) · 1.43 KB
/
Day4.js
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
76
77
78
79
80
81
// Task 1
for (let i = 1; i <= 10; i++) {
console.log(i);
}
console.log('----------------------------------');
// Task 2
let num = 5;
for (let i = 1; i <= 10; i++) {
console.log(`${num} * ${i} = ${num * i}`);
}
console.log('----------------------------------');
// Task 3
let i = 1;
while (i <= 10) {
console.log(i);
i++;
}
console.log('----------------------------------');
// Task 4
let j = 10;
while (j >= 1) {
console.log(j);
j--;
}
console.log('----------------------------------');
// Task 5
let a = 1;
do {
console.log(a);
a++;
} while (a <= 5);
console.log('----------------------------------');
// Task 6
let n = 5;
let b = 1, f = 1;
do {
f *= b;
b++;
} while (b <= n);
console.log(`The factorial of ${n} is ${f}`);
console.log('----------------------------------');
// Task 7: Method 1
var x,y,chr;
for(x=1; x <=6; x++)
{
for (y=1; y < x; y++)
{
chr=chr+("*");
}
console.log(chr);
chr='';
}
console.log('----------------------------------');
// Task 7: Method 2
for (let i = 1; i <= 5; i++) {
for (let j = 1; j <= i; j++){
process.stdout.write("*");
}
console.log();
}
console.log('----------------------------------');
// Task 8
for (let i = 1; i <= 10; i++) {
if (i == 5) continue;
console.log(i);
}
console.log('----------------------------------');
// Task 9
for (let i = 1; i <= 10; i++) {
if (i == 7) break;
console.log(i);
}