17_triangle.js 269 B

123456789
  1. let str = '';
  2. let strDots = '.';
  3. let strHash = '#';
  4. const rows = 6;
  5. for (let i = 0; i < rows; i++) {
  6. str += `${strDots.repeat((rows - 1) - i)}${strHash.repeat(((rows * 2) - 1) - (((rows - 1) - i) * 2))}${strDots.repeat((rows - 1) - i)}\n`;
  7. }
  8. console.log(str);