in JavaScript by
Q:
In the following code, what value should the variable "a" contain?

var x =counter(), y = counter();  

x.count()  

y.count()  

x.reset()  

x.count()  

y.count()  

a) Null

b) 0

c) 2

d) Undefined

► Click here to show 1 Answer

0 votes
by

Answer: C

Reason: The "counter()" method used in the above code made increment in the value of the variable by one each time it is called, and the" reset()" function resets the value of that variable to zero. Therefore if we look carefully, we can see that on variable "y" the "counter()" method was called two times, and the "reset()" method was not called even for one time, so the value of the variable y will be 2.

JavaScript
Learn More with Madanswer
...