JavaScript program to print Reverse Pyramid with alphabets
Following program shows you how to print reverse pyramid with alphabets using for loop.
let n = 5; // you can take input using prompt or change the value
let string = "";
// External loop
for (let i = 1; i <= n; i++) {
for (let j = 0; j < n - i + 1; j++) {
string += String.fromCharCode(j + 65);
}
string += "\n";
}
console.log(string);
Output:
ABCDE
ABCD
ABC
AB
A
Try it online here https://onecompiler.com/javascript/3x5qvexzy