E-Anchored Reverse Rows

Beginner
⏱️ 8 min read
📚 Updated: Aug 2025
🎯 2 Code Examples
Inner loop: E down to i

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:

Output
EDCBA
EDCB
EDC
ED
E
1

Node.js / console version

Outer loop increases i from start to end; inner loop runs j from end down to i:

JavaScript
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);
}
2

Browser version (document.write)

Same logic with ASCII codes 6569. Save as .html or use the live editor:

HTML
<!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

1

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.

Ascending i
2

Inner loop: from E down to i

for (let j = end; j >= i; j--) prints the reverse alphabet from E through i.

Same inner as Program 2
3

Line break

After each row, console.log(line) or document.write("<br>").

New row
=

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

Try These

  • Run Program 2 and compare row order line by line
  • Contrast with Program 7 (shrinks from the left toward A)
  • Change end to another letter and watch the triangle resize

Avoid

  • Using an inner loop from i down to A — that is Program 7, not E down to i
  • document.write after the document has loaded

Key Takeaways

1

Outer loop: A → E; inner loop: E → i (descending).

2

Each row always starts at E and shortens toward the right.

3

Total letters: \(n(n+1)/2\).

4

Same inner pattern as Program 2; outer direction reverses row order.

5

Time complexity: O(n²).

❓ Frequently Asked Questions

Same inner loop (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.
Program 7 prints from i down to A with outer i going E → A. Program 8 prints from E down to i with outer i going A → E.
O(n²) for n rows from A to E.

Next: JavaScript Alphabet Pattern 9

Continue to the next program in the alphabet pattern series.

Program 9 →
Did you know?

If you read Program 2’s output from the last line upward, you get exactly the same lines as this pattern for AE.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful