Print a table of numbers from 5 to 15 and their squares and cubes using alert in Internet Technologies

 <!DOCTYPE html>

<html>

<head>

  <style>

    table {

      border-collapse: collapse;

      width: 100%;

    }

    th, td {

      border: 1px solid black;

      padding: 8px;

      text-align: center;

    }


    th {

      background-color: #f2f2f2;

    }

  </style>

</head>

<body>


<table>

  <tr>

    <th>Number</th>

    <th>Square</th>

    <th>Cube</th>

  </tr>

  

  <!-- JavaScript code to populate the table -->

  <script>

    for (let num = 5; num <= 15; num++) {

      const square = num * num;

      const cube = num * num * num;


      document.write(`

        <tr>

          <td>${num}</td>

          <td>${square}</td>

          <td>${cube}</td>

        </tr>

      `);

    }

  </script>

</table>

</body>

</html>



Comments

Popular Posts