CodeToFun
Learn Programming Free
Tutorials
Languages
Features
About
Sign In
Tutorials
Languages
Features
About
Sign In
Back
/
JavaScript Alphabet Pattern 19
JavaScript Alphabet Pattern 19 (Try It — Browser)
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 19 - Try It (Browser)</title> <style> div.cell { display: inline-block; text-align: center; width: 13px; } </style> </head> <body> <h1>Mirror halves (document.write)</h1> <p>Edit the loops, then click Run.</p> <script> const A = 65; const top = 69; for (let i = A; i <= top; i++) { for (let j = A; j <= top; j++) { if (j <= i) document.write("<div class=\"cell\">" + String.fromCharCode(j) + "</div>"); else document.write("<div class=\"cell\"></div>"); } for (let k = top; k >= A; k--) { if (k > i) document.write("<div class=\"cell\"></div>"); else document.write("<div class=\"cell\">" + String.fromCharCode(k) + "</div>"); } document.write("<br>"); } </script> </body> </html>
Lines:
0
| Characters:
0
Live Preview
Auto-refresh on Run