This solution is generated by ChatGPT, correctness is not guaranteed. You might also be able to find a solution fromcommunity posts.
AI solution for JavaScript Quiz on BFE.dev
71. two-way generator
The code outputs:
undefined
100
undefined
Explanation:
generator.next().valuecalls the generator without passing any value. This means the firstyieldstatement evaluates toundefined, andconsole.logoutputsundefined.generator.next(1).valuepasses1as the value for the firstyieldstatement. This evaluates to100, andconsole.logoutputs100.generator.next(1).valuetries to pass another value to the generator, but there are no moreyieldstatements to be evaluated. This means the function simply ends and outputsundefined.