PrepAway - Latest Free Exam Questions & Answers

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?

PrepAway - Latest Free Exam Questions & Answers

A.
5, 10

B.
4, 9

C.
4, 5

D.
5, 5


Leave a Reply