[Solved] How to print a star pattern?


try this code

after i==1 create new pattern inside it

for (i = 3; i >= 1; i--) {
  /* Printing spaces */
  for (j = 0; j <= 3 - i; j++) {
    document.write("&nbsp");
  }
  /* Printing stars */
  k = 0;
  while (k != (2 * i - 1)) {
    document.write("*");
    k++;
  }

  document.write("<br/>")
  if (i == 1) {
    for (t = 2; t <= 3; t++) {

      for (j = 0; j <= 3 - t; j++) {
        document.write("&nbsp");
      }
      /* Printing stars */
      k = 0;
      while (k != (2 * t - 1)) {
        document.write("*");
        k++;
      }
      document.write("<br/>")
    }
  }
}

2

solved How to print a star pattern?