Table of Contents
show
Example:1C
Write a JavaScript to display square and cube of a number from 1 to 10 in web browser
Script
<html>
<head>
<title>
Displaying square and cube
</title>
</head>
<body>
<table border = 1 align ="center">
<th> Number</th>
<th> Square</th>
<th>Cube</th>
<script type "text/javascript" src="displaysqr.js"> </script>
</table>
</body>
</html>
for (let i = 1; i <= 10; i++) {
document.write(
"<tr><td>" +
i +
"</td><td>" +
i * i +
"</td><td>" +
i * i * i +
"</td></tr>"
);
}
Output
Views: 12