Practical – 119.1 : Create Dynamic Triangle Pyramid
Program Code :Â
<!DOCTYPE html>
<html>
<head>
 <title>Dynamic Triangle Pyramid</title>
 <style>
   body {
     font-family: Arial, sans-serif;
     text-align: center;
     padding: 30px;
   }
   input, button {
     font-size: 16px;
     padding: 8px;
     margin: 10px;
   }
   pre {
     font-family: monospace;
     font-size: 18px;
     line-height: 1.4;
   }
 </style>
</head>
<body>
 <h2>Dynamic Triangle Pyramid Generator</h2>
 <label>Enter number of rows:</label>
 <input type=”number” id=”rows” min=”1″ value=”5″>
 <button onclick=”createPyramid()”>Generate</button>
 <pre id=”pyramidOutput”></pre>
 <script>
   function createPyramid() {
     let rows = parseInt(document.getElementById(“rows”).value);
     let output = “”;
     for (let i = 1; i <= rows; i++) {
       let stars = “*”.repeat(i);
       output += stars + “\n”;
     }
     document.getElementById(“pyramidOutput”).textContent = output;
   }
 </script>
</body>
</html>