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 — 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 29 - Try It (Browser)</title> <style> div.cell { display: inline-block; text-align: center; width: 15px; } </style> </head> <body> <h1>Full square (document.write)</h1> <p>Edit the loops, then click Run.</p> <script> const A = 65; const top = 69; function printRow(i) { for (let j = top; j >= A; j--) { if (j > i) document.write("<div class=\"cell\">" + String.fromCharCode(j) + "</div>"); else document.write("<div class=\"cell\">" + String.fromCharCode(i) + "</div>"); } for (let j = A + 1; j <= top; j++) { if (j > i) document.write("<div class=\"cell\">" + String.fromCharCode(j) + "</div>"); else document.write("<div class=\"cell\">" + String.fromCharCode(i) + "</div>"); } document.write("<br>"); } for (let i = top; i >= A; i--) printRow(i); for (let i = A + 1; i <= top; i++) printRow(i); </script> </body> </html>
Lines:
0
| Characters:
0
Live Preview
Auto-refresh on Run