Create a Web page named hail.html that computes and displays hailstone sequences. The user should be able

Question:

Create a Web page named hail.html that computes and displays hailstone sequences. The user should be able to enter a positive integer in a text box and then click a button. When the button is clicked, the hailstone sequence starting with the input number should appear in a separate text area, one number per line. If the sequence gets to 1 (meaning it is stuck in the 4-2-1 loop), then your code should print the word "STUCK!" in the text area and terminate. Include a variable that records and displays the length of the hailstone sequence (up to the point where 1 is reached). For example, the hailstone sequence starting with 5 would be displayed as:

5

16

8

4

2

1

STUCK!

Hailstone sequence length: 6

[There are many different ways to test whether a number is even or odd. For example, if num/2 is equal to Math.floor(num/2), then num is an even number. Likewise, because the % operator computes the remainder left over after division, the expression (num % 2 == 0), evaluates to true only if num is even.]

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: