bacco

Diamond

Mar 13th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function house([arge1]){
  2.     let n = Number(arge1);
  3.     var a = Math.floor((n - 1) / 2 - 1);
  4.     var b = 0;
  5.     var c = Math.floor( (n - 1) / 2);
  6.     var d = n - c - c;
  7.  
  8.      console.log("-".repeat(c) + "*".repeat(d) + "-".repeat(c) );
  9. for (i = 1; i < (n ) / 2 ; i++) {
  10.      b = n - a - a -2 ;
  11.     console.log("-".repeat(a) + "*" + "-".repeat(b) + "*" + "-".repeat(a) );
  12.     a--;
  13.     }
  14.     a = 1;
  15. for (i = 1; i < (n ) / 2 - 1 ; i++) {
  16.  
  17.     var b = n - a - a - 2 ;
  18.     console.log("-".repeat(a) + "*" + "-".repeat(b) + "*" + "-".repeat(a) );
  19.     a++;
  20.     }
  21.     console.log("-".repeat(c) +  "*".repeat(d) + "-".repeat(c) );
  22. }
  23. house([8])
  24.  
  25. //                  ---**---
  26. //                  --*--*--
  27. //                  -*----*-
  28. //                  *------*
  29. //                  -*----*-
  30. //                  --*--*--
  31. //                  ---**---
Advertisement
Add Comment
Please, Sign In to add comment