CodeToFun
Learn Programming Free
Tutorials
Languages
Features
About
Sign In
Tutorials
Languages
Features
About
Sign In
Back
/
JavaScript Alphabet Pattern 34
JavaScript Alphabet Pattern 34 (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 34 - Try It (Browser)</title> </head> <body> <h1>Diamond (document.write)</h1> <p>Edit the loops, then click Run.</p> <script> const A = 65; const last = 69; function printRow(i) { for (let j = last; j >= A; j--) { if (i === j) document.write(String.fromCharCode(j)); else document.write(" "); } for (let k = A + 1; k <= last; k++) { if (i === k) document.write(String.fromCharCode(k)); else document.write(" "); } document.write("<br>"); } for (let i = A; i <= last; i++) printRow(i); for (let i = last - 1; i >= A; i--) printRow(i); </script> </body> </html>
Lines:
0
| Characters:
0
Live Preview
Auto-refresh on Run