Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function house([arge1]){
- let n = Number(arge1);
- var a = Math.floor((n - 1) / 2 - 1);
- var b = 0;
- var c = Math.floor( (n - 1) / 2);
- var d = n - c - c;
- console.log("-".repeat(c) + "*".repeat(d) + "-".repeat(c) );
- for (i = 1; i < (n ) / 2 ; i++) {
- b = n - a - a -2 ;
- console.log("-".repeat(a) + "*" + "-".repeat(b) + "*" + "-".repeat(a) );
- a--;
- }
- a = 1;
- for (i = 1; i < (n ) / 2 - 1 ; i++) {
- var b = n - a - a - 2 ;
- console.log("-".repeat(a) + "*" + "-".repeat(b) + "*" + "-".repeat(a) );
- a++;
- }
- console.log("-".repeat(c) + "*".repeat(d) + "-".repeat(c) );
- }
- house([8])
- // ---**---
- // --*--*--
- // -*----*-
- // *------*
- // -*----*-
- // --*--*--
- // ---**---
Advertisement
Add Comment
Please, Sign In to add comment