CodeToFun
Learn Programming Free
Tutorials
Languages
Features
About
Sign In
Tutorials
Languages
Features
About
Sign In
Back
/
JavaScript Alphabet Pattern 31
JavaScript Alphabet Pattern 31 (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 31 - Try It (Browser)</title> </head> <body> <h1>Two diagonals (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 (i === j) document.write(String.fromCharCode(j)); else document.write(" "); } for (let k = top - 1; k >= A; k--) { if (i === k) document.write(String.fromCharCode(k)); else document.write(" "); } document.write("<br>"); } </script> </body> </html>
Lines:
0
| Characters:
0
Live Preview
Auto-refresh on Run