how to log a dimand shape in javascript

Solutions on MaxInterview for how to log a dimand shape in javascript by the best coders in the world

showing results for - "how to log a dimand shape in javascript"
Anael
18 Aug 2017
1function createDimondShape(size){
2   for(var i=1;i<=size;i++){
3      for(var s=size-1;s>=i;s--){
4         process.stdout.write(" ");
5      }
6      for(var j=1;j<=i;j++){
7         process.stdout.write("* ")
8      }
9      console.log();
10   }
11   if(i==size+1){
12      for(var i=1;i<=size-1;i++){
13         for(var s=1;s<=i;s++){
14            process.stdout.write(" ");
15         }
16         for(j=i;j<=size-1;j++){
17            process.stdout.write("* ");
18         }
19         console.log();
20      }
21   }
22}
23createDimondShape(9);