-
Notifications
You must be signed in to change notification settings - Fork 0
/
4.js
45 lines (36 loc) · 808 Bytes
/
4.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
function cetak(piro){
let a = [];
let lihat = ''
let l = ''
for (let i = 0; i < piro; i++) {
a.push([]);
}
let iki = piro - 1;
for (let i = 0; i < piro; i++) {
for (let i = 0; i < piro; i++) {
a[i][i] = 'X';
l = piro - (i + 1)
a[i][l] = 'X';
}
l--
}
for (let i = 0; i < piro; i++) {
for (let l = 0; l < piro; l++) {
if (a[i][l] == 'X'){
lihat += 'X '
} else {
lihat += '= '
}
}
lihat += '\n'
}
return lihat
}
function proses(iku){
if (iku % 2 == 0){
console.log('Angka harus ganjil');
} else {
console.log(cetak(iku));
}
}
proses(11);