forked from kokonior/Javascript-Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanfasa.js
58 lines (48 loc) · 1.27 KB
/
anfasa.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
<script>
// JavaScript program to print the
// arrow pattern
// Function to print pattern
function print_arrow(n)
{
// for printing upper part
// of the arrow
for (var i = 1; i < n; i++)
{
// To give space before printing
// stars in upper part of arrow
for (var j = 0; j < i; j++)
{
document.write(" ");
}
// To print stars in upper
// part of the arrow
for (var k = 0; k < i; k++) {
document.write("*");
}
document.write("<br>");
}
// for printing lower part
// of the arrow
for (var i = 0; i < n; i++)
{
// To give space before printing
// stars in lower part of arrow
for (var j = 0; j < n - i; j++)
{
document.write(" ");
}
// To print stars in lower
// part of the arrow
for (var k = 0; k < n - i; k++)
{
document.write("*");
}
document.write("<br>");
}
}
// Driver code
// taking input from user
var n = 5;
// function calling
print_arrow(n);
</script>