CodeToFun
Learn Programming Free
Tutorials
Languages
Features
About
Sign In
Tutorials
Languages
Features
About
Sign In
Back
/
JavaScript Alphabet Pattern 16
JavaScript Alphabet Pattern 16 (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 16 - Try It</title> <style> body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; } #output { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 20px; line-height: 1.35; white-space: pre; margin-top: 12px; } </style> </head> <body> <h1>Spaced pyramid (console)</h1> <p>Edit the loops or <code>pad</code>, then click Run.</p> <pre id="output"></pre> <script> (() => { const A = "A".charCodeAt(0); const top = "E".charCodeAt(0); let k = A; // In a <pre>, regular spaces are preserved, so plain spaces align reliably. const pad = " "; let result = ""; for (let i = A; i <= top; i += 2) { let line = ""; for (let j = top; j >= A; j--) { if (j > i) line += pad; else line += String.fromCharCode(k++) + pad; } result += line + "\n"; } document.getElementById("output").textContent = result; })(); </script> </body> </html>
Lines:
0
| Characters:
0
Live Preview
Auto-refresh on Run