what will be the final value of x?

Consider the following code:
<script>
var x = 0;
for (i=0; i<5; i++) {
x += i;
}
alert(“1+2+3+4 = ” +x);
</script>
How many times will the program loop, and what will be the final value of x?

Consider the following code:
<script>
var x = 0;
for (i=0; i<5; i++) {
x += i;
}
alert(“1+2+3+4 = ” +x);
</script>
How many times will the program loop, and what will be the final value of x?

A.
5, 10

B.
4, 9

C.
4, 5

D.
5, 5



Leave a Reply 0

Your email address will not be published. Required fields are marked *