E-Anchored Reverse Rows

What You'll Learn
Every row starts at E and prints downward in the alphabet (reverse order): EDCBA, then letters drop from the right as i moves A → E: EDCB, EDC, ED, E. The inner loop is the same idea as Program 2; only the outer loop direction changes.
Total letters printed is \(5 + 4 + 3 + 2 + 1 = 15 = n(n+1)/2\) for five rows.
⭐ Pattern Output
Five rows as i moves from A to E:
EDCBA
EDCB
EDC
ED
ENode.js / console version
Outer loop increases i from start to end; inner loop runs j from end down to i:
const start = "A".charCodeAt(0);
const end = "E".charCodeAt(0);
for (let i = start; i <= end; i++) {
let line = "";
for (let j = end; j >= i; j--) {
line += String.fromCharCode(j);
}
console.log(line);
}Browser version (document.write)
Same logic with ASCII codes 65–69. Save as .html or use the live editor:
<!DOCTYPE html>
<html>
<body>
<script>
for (let i = 65; i <= 69; i++) {
for (let j = 69; j >= i; j--) {
document.write(String.fromCharCode(j));
}
document.write("<br>");
}
</script>
</body>
</html>🧠 How It Works
Outer loop: lower bound of the row
for (let i = start; i <= end; i++) moves the smallest character printed on each row from A up to E.
iInner loop: from E down to i
for (let j = end; j >= i; j--) prints the reverse alphabet from E through i.
Line break
After each row, console.log(line) or document.write("<br>").
Program 2, flipped order
The multiset of rows matches Program 2; listing Program 2’s output from bottom to top matches this page. Complexity O(n²).
💡 Tips for Enhancement
Key Takeaways
Outer loop: A → E; inner loop: E → i (descending).
Each row always starts at E and shortens toward the right.
Total letters: \(n(n+1)/2\).
Same inner pattern as Program 2; outer direction reverses row order.
Time complexity: O(n²).
❓ Frequently Asked Questions
j from E down to i). Program 2 decrements the outer i from E to A, so short rows print first. Program 8 increments i, so EDCBA prints first.i down to A with outer i going E → A. Program 8 prints from E down to i with outer i going A → E.n rows from A to E.Next: JavaScript Alphabet Pattern 9
Continue to the next program in the alphabet pattern series.
If you read Program 2’s output from the last line upward, you get exactly the same lines as this pattern for A–E.
10 people found this page helpful
