Right Triangle Pattern in JavaScript | Stackblitz

 

Below Code With Demo

     *
   **
  ***
 ****
****

let n = 5;
let string = "";
for (let i = 1i <= ni++) {
  // printing spaces
  for (let j = 0j < n - ij++) {
    string += " ";
  }
  // printing star
  for (let k = 0k < ik++) {
    string += "*";
  }
  string += "\n";
}
console.log(string);





No comments:

Post a Comment

starter ASP.NET Core Web API project with example

Starter ASP.NET Core Web API project that follows all the best practices listed above. 🛠️ Starter Project Overview We’ll build a Produc...

Best for you