CodeToFun
Learn Programming Free
Tutorials
Languages
Features
About
Sign In
Tutorials
Languages
Features
About
Sign In
Back
/
JavaScript Number Pattern 25
JavaScript Number Pattern 25 (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 Number Pattern 25 - Try It</title> </head> <body> <h1>Repeating Number Pattern (Decreasing Length)</h1> <p>Edit <code>rows</code> and click Run.</p> <pre id="output"></pre> <script> const rows = 5; let result = ""; for (let i = 1; i <= rows; i++) { const count = rows - i + 1; const value = i < 4 ? i : (rows + 1 - i); result += String(value).repeat(count) + "\n"; } document.getElementById("output").textContent = result; </script> </body> </html>
Lines:
0
| Characters:
0
Live Preview
Auto-refresh on Run