-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexercise-7.js
44 lines (34 loc) · 845 Bytes
/
exercise-7.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
/**************************
1. Menyusun Barisan Bintang
*/
var rows1 = 5; // input the number of rows
// do loops to display asterisks in the console.
for (var i = 1; i <= rows1; i++) {
console.log('*');
}
/**************************
2. Menyusun Barisan Bintang Dengan Nested Looping
*/
console.log('\n');
var rows2 = 5; // input the number of rows
// do loops to display asterisks in the console.
for (var i = 1; i <= rows2; i++) {
var k = '';
for (var j = 1; j <= rows2; j++) {
k += '*';
}
console.log(k);
}
/**************************
3. Menyusun Barisan Tangga Bintang Dengan Nested Looping
*/
console.log('\n');
var rows3 = 5; // input the number of rows
// do loops to display asterisks in the console.
for (var i = 1; i <= rows2; i++) {
var k = '';
for (var j = 1; j <= i; j++) {
k += '*';
}
console.log(k);
}