var product = 0;
while (count < 4) {
sum += count;
product *= count;
if (count == 4)
alert("Sum = " + sum);
alert("Product = " + product);
count++;
}
3.
[after Section 10.5] Assume the following code is part of a working web page.
What message
will
console.log
display?
var userTurn = true;
var userTurns = computerPoints = 0;
do {
if (userTurn) {
userTurns++;
}
else {
computerPoints++;
}
userTurn = !userTurn;
} while (userTurns < 2);
console.log("computer points: " + computerPoints);
4.
[after Section 10.5] Suppose you have a variable named
quantity
that holds a number.
Provide an
if
statement heading that checks to see whether
quantity
holds a whole number.
5.
[after Section 10.9] Given the following web page code that generates
the factorial for a user-
entered number. Provide a standard
for
loop that could
be used to replace the
while
loop.
Factorial Generator
Do'stlaringiz bilan baham: