This question is a real head-scratcher! I'm going to go with B) 0 1 2 3 because it just makes the most sense to me. But who knows, maybe the exam writers are trying to trick us with this one.
I'm confused. Shouldn't the answer be C) 0 1 1 2? The first logCounter() call logs 0, the setTimeout call logs 1, and the setInterval call increments Counter and logs the new value, but the last log statement should be 2, not 3.
No, that's not correct. The first logCounter() call logs 0, the setTimeout call logs 0 again, and the setInterval call increments Counter and logs the new value.
I'm going with D) 0 1 2 2. The setInterval call increments Counter and logs the new value, but the last log statement should be 2 since the interval is 1 second and the setTimeout is 1.1 seconds.
I think it's A) 0 0 1 2. The first log statement logs the initial value of Counter, which is 0. Then the setInterval increments Counter and logs it, so it goes 0 0 1 2.
I think the answer is B) 0 1 2 3. The code sets the Counter variable to 0, and then the first logCounter() call logs 0. The setTimeout call logs 0 after 1.1 seconds, and the setInterval call increments Counter and logs the new value every 1 second, so the output should be 0 1 2 3.
Edwin
1 months agoStephaine
19 hours agoMila
1 months agoDante
1 months agoGalen
1 months agoBrande
10 days agoLeonida
14 days agoPatria
24 days agoKami
2 months agoMona
5 days agoTruman
10 days agoThora
25 days agoDewitt
1 months agoGolda
1 months agoMichel
2 months agoPura
2 months agoMargret
1 months agoAlex
1 months agoTabetha
2 months agoTorie
2 months agoMatthew
2 months agoMichel
3 months ago