Downward Triangle Star Pattern in Javascript

Downward Triangle Star Pattern in JavaScript  to create a downward triangle star pattern use a nested loops, it's  also known as a reverse star patterns. From the above-shown patterns, you can see the numbers of stars decreases from 'n' to 1.

*****

****

***

**

*



Source Code:

// Write Javascript code!
let n = 5;
let string = "";
for (let i = 0i < ni++) {
  // printing star
  for (let k = 0k < n - ik++) {
    string += "*";
  }
  string += "\n";
}
document.getElementById('app').innerText = string
//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