G2A Many GEOs
SHARE
TWEET

House figure

RRusev77 Apr 6th, 2020 183 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(num){
  2.     num = Number(num);
  3.  
  4.     let isNumOdd = num % 2 == 0; // true / false
  5.     let roof = Math.floor((num + 1) / 2); // defines how much rows for the roof
  6.     let stars;
  7.     let subtract;
  8.  
  9.     // roof
  10.     if(isNumOdd){
  11.         console.log('-'.repeat((num - 2) / 2) + '**' + '-'.repeat((num - 2) / 2));
  12.         stars = 2;
  13.     } else {
  14.         console.log('-'.repeat((num - 1) / 2) + '*' + '-'.repeat((num - 1) / 2));
  15.         stars = 1;
  16.     }
  17.  
  18.     for(let i = 1; i < roof; i++) {
  19.         stars += 2;
  20.         subtract = (num - stars) / 2;
  21.         console.log('-'.repeat(subtract) + '*'.repeat(stars) + '-'.repeat(subtract));
  22.     }
  23.  
  24.     // house
  25.     let houseRows = num - roof;
  26.  
  27.     for(let i = 1; i <= houseRows; i++) {
  28.         console.log('|' + '*'.repeat(num - 2) + '|');
  29.     }
  30. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top