What's bad about that? It's obviously testing understanding of scoping and side effects. It's not hard if you understand those things and confusing if you don't, which seems like the kind of question you'd want on a "general coding assessment", no?
The only thing that bugs me about that question is that "the output of the following function" is confusingly worded. It's the sort of question that a competent candidate might get nervous about and start to overthink: wait, that isn't a function, it's a code snippet. The function here is foo – so maybe they mean "what's the output of foo"? But then what does "the output of a function" mean? I suppose they mean return value? Is this a trick question to see if I remember what push returns? Damn it, does it return the entire array or just the pushed element?
That's what my mind usually does with questions like that and I'm far from the only one. Since the goal of the test is to screen for basic competence, it ought not to filter out people who could answer the question perfectly fine if it were being asked clearly, but who also perceive corner cases and ambiguities. Such a skill should make you more likely to pass such a test, not less. Therefore the question ought to say something like "What does the following code snippet write to the console?"
As you say, any competent programmer could solve this in a few seconds, if they are proficient, or minutes if they are not.
In my opinion, they should not put a count down because they are interrupting the programmer’s flow. If they really want to measure time, they do it without interrupting the programmer, hide the timer, let them take as much time as they want/need to solve these problems. Then, at the end of the quiz, show them how long it took them to give a proper solution, and take in consideration that time to score them.
If Alice solved 10 problems in 10 minutes, and Bob solved the same problems in 15 minutes, maybe there is something there that is worth highlighting in their profiles. Maybe Alice is able to analyze this type of questions much faster than Bob, and if that matters to the recruiters or potential employers, then allow the candidate to use that in their favor.
However, if Bob actually knew the answer, but they ran out of time to select an option, that seems unfair.
The only thing that bugs me about that question is that "the output of the following function" is confusingly worded. It's the sort of question that a competent candidate might get nervous about and start to overthink: wait, that isn't a function, it's a code snippet. The function here is foo – so maybe they mean "what's the output of foo"? But then what does "the output of a function" mean? I suppose they mean return value? Is this a trick question to see if I remember what push returns? Damn it, does it return the entire array or just the pushed element?
That's what my mind usually does with questions like that and I'm far from the only one. Since the goal of the test is to screen for basic competence, it ought not to filter out people who could answer the question perfectly fine if it were being asked clearly, but who also perceive corner cases and ambiguities. Such a skill should make you more likely to pass such a test, not less. Therefore the question ought to say something like "What does the following code snippet write to the console?"