CodeToFun
Learn Programming Free
Tutorials
Languages
Features
About
Sign In
Tutorials
Languages
Features
About
Sign In
Back
/
JavaScript Alphabet Pattern 22
JavaScript Alphabet Pattern 22 (Try It)
Try It
Run
Reset
Save
Save to Google Drive
Sync with your Google account
Download HTML
Save to your device
Share
Full
HTML Code
Copy
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JS Alphabet Pattern 22 - Try It</title> </head> <body> <h1>Consecutive letters pyramid</h1> <p>Edit <code>top</code> to change the number of rows, then click Run.</p> <pre id="output"></pre> <script> (() => { const A = "A".charCodeAt(0); const top = "E".charCodeAt(0); let k = A; let result = ""; for (let i = A; i <= top; i++) { let line = ""; for (let j = top; j >= A; j--) { if (j > i) line += " "; else line += String.fromCharCode(k++) + " "; } result += line.trimEnd() + "\n"; } document.getElementById("output").textContent = result; })(); </script> </body> </html>
Lines:
0
| Characters:
0
Live Preview
Auto-refresh on Run