CodeToFun
Learn Programming Free
Tutorials
Languages
Features
About
Sign In
Tutorials
Languages
Features
About
Sign In
Back
/
JavaScript Alphabet Pattern 29
JavaScript Alphabet Pattern 29 (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 29 - Try It</title> </head> <body> <h1>Full symmetric square (E..A..E)</h1> <p>Edit <code>top</code> or <code>j > i</code>, then click Run.</p> <pre id="output"></pre> <script> (() => { const A = "A".charCodeAt(0); const top = "E".charCodeAt(0); function row(i) { let line = ""; for (let j = top; j >= A; j--) line += (j > i ? String.fromCharCode(j) : String.fromCharCode(i)) + " "; for (let j = A + 1; j <= top; j++) line += (j > i ? String.fromCharCode(j) : String.fromCharCode(i)) + " "; return line.trimEnd(); } let result = ""; for (let i = top; i >= A; i--) result += row(i) + "\n"; for (let i = A + 1; i <= top; i++) result += row(i) + "\n"; document.getElementById("output").textContent = result; })(); </script> </body> </html>
Lines:
0
| Characters:
0
Live Preview
Auto-refresh on Run