SHARE
TWEET

Untitled

a guest May 20th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let builder = {
  2.     // Main method for initializing logo rows
  3.     buildLogo: function (number) {
  4.         if (builder.validateNumber(number) === true) {
  5.             let symbols = builder.getSymbols();
  6.  
  7.             builder.generateTopPart(number, symbols);
  8.             builder.generateBottomPart(number, symbols);
  9.         } else {
  10.             //Throw error message
  11.             console.log('Oops, wrong number value');
  12.         }
  13.     },
  14.     generateTopPart: function (number, symbols) {
  15.         let rowLength = (number + 1) / 2;
  16.         let outerBackground = number;
  17.         let innerForeground = number;
  18.         let middleBackground = number;
  19.  
  20.         for (let row = rowLength; row > 0; row--) {
  21.             let halfTopPartLogo =
  22.                 symbols.background.repeat(outerBackground) + symbols.foreground.repeat(innerForeground) +
  23.                 symbols.background.repeat(middleBackground) + symbols.foreground.repeat(innerForeground) +
  24.                 symbols.background.repeat(outerBackground);
  25.  
  26.             console.log(halfTopPartLogo.repeat(2));
  27.  
  28.             outerBackground--;
  29.             innerForeground += 2;
  30.             middleBackground -= 2;
  31.         }
  32.     },
  33.     generateBottomPart: function (number, symbols) {
  34.         let rowLength = Math.floor((number + 1) / 2);
  35.         let middleBackground = 1;
  36.         let middleForeground = (number * 2) - 1;
  37.         for (let row = rowLength; row > 0; row--) {
  38.             let halfBottomPart =
  39.                 symbols.background.repeat(row - 1) + symbols.foreground.repeat(number) +
  40.                 symbols.background.repeat(middleBackground) + symbols.foreground.repeat(middleForeground) +
  41.                 symbols.background.repeat(middleBackground) + symbols.foreground.repeat(number) + symbols.background.repeat(row - 1);
  42.  
  43.             console.log(halfBottomPart.repeat(2));
  44.  
  45.             middleBackground += 2;
  46.             middleForeground -= 2;
  47.         }
  48.     },
  49.     validateNumber: function(number) {
  50.         if (number % 2 !== 0 && number > 2 && number < 10000) {
  51.             return true;
  52.         }
  53.         return false;
  54.     },
  55.     getSymbols: function () {
  56.         return {
  57.             background: '-',
  58.             foreground: '*'
  59.         };
  60.     }
  61. };
  62.  
  63. builder.buildLogo(7);
RAW Paste Data
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