-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy patharrow4.js
51 lines (44 loc) · 1.28 KB
/
arrow4.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
//User Input and error message
var sizeArrow = process.argv[2]
if (sizeArrow < 2 || sizeArrow > 20 || isNaN(sizeArrow)) {
console.error("ERROR you need to type a number between 2 and 20")
process.exit(1)
}
//Run the print function
headPrint(sizeArrow);
bodyPrint(sizeArrow);
basePrint(sizeArrow);
tailPrint(sizeArrow);
//Print the head arrow
function headPrint(sizeArrow){
head = " ".repeat(sizeArrow -1)+ "*";
console.log(head)
}
//Print the body arrow
function bodyPrint(sizeArrow){
arrowBodyLength = sizeArrow -2
numberSpaceBefore = sizeArrow -2
numberSpaceBetween = 1
for (var i = 0; i < arrowBodyLength; i++){
body = " ".repeat(numberSpaceBefore) + "*" + " ".repeat(numberSpaceBetween) + "*"
numberSpaceBetween = numberSpaceBetween +2
numberSpaceBefore = numberSpaceBefore -1
console.log(body);
}
}
//Print the base arrow
function basePrint(sizeArrow){
starNumberRepeat = sizeArrow*2 -1
base = "*".repeat(starNumberRepeat)
console.log(base)
}
//Print the tail arrow
function tailPrint(sizeArrow){
tail = " ".repeat(sizeArrow -1) + "*\n"
fullTail = tail.repeat(sizeArrow -1)
console.log(fullTail)
}
//Repeat character
function repeatCharacter(caracter,repeatnumber){
return caracter.repeat(repeatnumber)
}