-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercise-6.js
83 lines (79 loc) · 1.59 KB
/
exercise-6.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
82
83
//Looping
//1. Melakukan Looping Menggunakan While
console.log('1. Melakukan Looping Menggunakan While');
console.log('LOOPING PERTAMA');
var pertama = 20;
var p = 1;
while (p<pertama+1) {
if (p%2==0) {
console.log(p+' - I love coding');
}
else {};
p++;
}
console.log('LOOPING KEDUA');
var kedua = 20;
var k = 1;
while (kedua>k) {
if (kedua%2==0) {
console.log(kedua+' - I will become fullstack developer');
}
else {};
kedua--;
}
console.log('');
//2. Melakukan Looping Menggunakan For
console.log('2. Melakukan Looping Menggunakan For');
console.log('LOOPING PERTAMA');
var for1 = 20;
for(let i = 1; i<for1+1; i++) {
console.log(i+' - I love coding');
}
console.log('LOOPING KEDUA');
var for2 = 20;
for(let i = for2; i>0; i--) {
console.log(i+' - I will become fullstack developer');
}
console.log('');
//3. Angka Ganjil dan Genap
console.log('3. Angka Ganjil dan Genap');
console.log('<---------------PART 1--------------->');
var satu = 100;
for (let i=1; i<satu+1; i++) {
if (i%2==0) {
console.log('"GENAP"')
}
else{
console.log('"GANJIL"')
}
}
console.log('<---------------PART 2--------------->');
var satu = 100;
for (let i=1; i<satu+1; i+=2) {
if (i%3==0) {
console.log(i+' KELIPATAN 3')
}
else{
console.log('""')
}
}
console.log('<---------------PART 3--------------->');
var satu = 100;
for (let i=1; i<satu+1; i+=5) {
if (i%6==0) {
console.log(i+' KELIPATAN 6')
}
else{
console.log('""')
}
}
console.log('<---------------PART 4--------------->');
var satu = 100;
for (let i=1; i<satu+1; i+=9) {
if (i%10==0) {
console.log(i+' KELIPATAN 10')
}
else{
console.log('""')
}
}