Predict the output sequences that would be produced by each of the following while loops: count =

Question:

Predict the output sequences that would be produced by each of the following while loops:

count = 10;

while (count > 0) {

document.getElementById('outputDiv').innerHTML =

document.getElementById('outputDiv').innerHTML + count + '<br>';

count = count - 2;

}

document.getElementById('outputDiv').innerHTML =

document.getElementById('outputDiv').innerHTML + 'DONE WITH 1ST!<br>';

num = 1;

while (num <= 5) {

document.getElementById('outputDiv').innerHTML =

document.getElementById('outputDiv').innerHTML + num + '<br>';

num = num + 1;

}

document.getElementById('outputDiv').innerHTML =

document.getElementById('outputDiv').innerHTML + 'DONE WITH 2ND!<br>';

x = 1;

y = 10;

while (x < y) {

document.getElementById('outputDiv').innerHTML =

document.getElementById('outputDiv').innerHTML + x + ' ' + y + '<br>';

x = x + 1;

y = y - 2;

}

document.getElementById('outputDiv').innerHTML =

document.getElementById('outputDiv').innerHTML + 'DONE WITH 3RD!<br>';

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

Step by Step Answer:

Question Posted: