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

CPU vs GPU Architecture

  CPU vs GPU Architecture CPU (Central Processing Unit) and GPU (Graphics Processing Unit) have distinct architectural differences, optimize...

Best for you