+ 3
If you actually called the function.
var x = 1:
var y = 4;
function func() {
while (x > 0) {
x++;
y--;
}
}
func();
document.write(x)
+ 3
First program:
The function never executes. It won't do anything to the program, since it wasn't called.
Second program:
The push is a method of the array prototype. arr[0] is 1, a number, and since I remember numbers are not arrays, and there isn't a push method for numbers, therefore it will cause an error
+ 2
No, that's not what I'm saying. The while loop, as you can see, is wrapped inside the func function. You might have heard, but functions are only executed, when they are called. The func function is never called, therefore the while loop doesn't execute. If it wouldn't be inside a function, yes, x would be 5
+ 1
The function in the first program will only execute if you add func() to your program. Youâve defined it but not called it. Also, unless x and y are global variables, the function wonât recognize them. You can fix this easily by changing the function to accept two values func(x,y), and then pass these two values when you call the function.



