-
Notifications
You must be signed in to change notification settings - Fork 17
/
arrow3.js
55 lines (45 loc) · 1.19 KB
/
arrow3.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
var input = (padding = process.argv[2]);
if (input <= 2 || input > 20 || isNaN(input)) {
console.error("Please enter a valid input between 2 and 20 !");
process.exit(1);
}
var queuestring = "";
var midstring = "";
var tetestring = "";
function tete(n) {
let number;
number = n - 1;
let spacebetween = 1;
for (let i = 0; i < n - 1; i++) {
if (spacebetween == 1) {
tetestring = tetestring + `${" ".repeat(number)}*\n`;
} else if (spacebetween == 2) {
tetestring = tetestring + `${" ".repeat(number)}*${" ".repeat(1)}*\n`;
} else {
tetestring =
tetestring +
`${" ".repeat(number)}*${" ".repeat(spacebetween + i - 2)}*\n`;
}
spacebetween = spacebetween + 1;
number = number - 1;
}
return tetestring;
}
function mid(n) {
for (let i = 0; i < n * 2 - 1; i++) {
midstring = midstring + `*`;
}
return midstring + `\n`;
}
function queue(n) {
for (let i = 0; i < n; i++) {
if (i == n - 1) {
queuestring = queuestring + `${" ".repeat(n - 1)}*`;
} else {
queuestring = queuestring + `${" ".repeat(n - 1)}*\n`;
}
}
return queuestring;
}
let fleche = tete(input) + mid(input) + queue(input);
console.log(fleche);