Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a JavaScript program which will ask user to enter two number between 1 and

ID: 3727130 • Letter: W

Question

Write a JavaScript program which will ask user to enter two number between 1 and 20. Your program will then output the number, its square, and its cube from the smaller number to the larger number one at a row For example, if user enters 3 and 7 as shown below, your program will output, umbers from 3 to 7, and their squares and cubes This page says: This page says: Enter a number between 1 and 20 Enter a number between 1 and 20: OK Cancel OK Cancel number cube 27 64 125 216 343 square 16 25 36 49

Explanation / Answer

Following is the javascript code:

<html>
<head>
<script>

var n1 = prompt("Enter a number between 1 and 20");
var n2 = prompt("Enter a number between 1 and 20");

document.write("<table border=1>")
document.write(" <tr> <th>Number</th> <th>Square</th> <th>Cube</th> </tr>" )
for(var n=n1; n<=n2; n++)
{
document.write( "<tr><td><center>" + n + "</center></td><td><center>" + n*n + "</center></td><td><center>" + n*n*n + "</center></td></tr>" )
}
document.write( "</table>" )
</script>
</head>
<body>
</body>
</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote