-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLetter Diamond.js
More file actions
44 lines (43 loc) · 853 Bytes
/
Copy pathLetter Diamond.js
File metadata and controls
44 lines (43 loc) · 853 Bytes
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
/*Basicly the diamond shape thingy, but with letters instead of asterisks
ex: 3 would be the following
··A··
·B·B·
C···C
·B·B·
··A··*/
var alph=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
var num=prompt("Enter number."), wrd="";
for(var x=0;x<num;x++){
for(var y=1;y<num-x;y++){
wrd+="*";
}
for(var y=0;y<((x+1)*2)-1;y++){
if(y===0||y==((x+1)*2)-2){
wrd+=alph[x];
}else{
wrd+="*";
}
}
for(var y=1;y<num-x;y++){
wrd+="*";
}
console.log(wrd);
wrd="";
}
for(var x=num-2;x>=0;x--){
for(var y=1;y<num-x;y++){
wrd+="*";
}
for(var y=0;y<((x+1)*2)-1;y++){
if(y===0||y==((x+1)*2)-2){
wrd+=alph[x];
}else{
wrd+="*";
}
}
for(var y=1;y<num-x;y++){
wrd+="*";
}
console.log(wrd);
wrd="";
}