A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-111.js
1function*g(){
2constx=yield'ask';
3console.log('got '+x);
4}
5constit=g();
6it.next();
7it.next(42);
Async
Answer & explanation
Console output
got 42
Why
Inside a generator, a yield expression can receive a value: whatever you pass to the next next() call becomes the value the paused yield evaluates to. The first next() runs until the yield and pauses. The second next(42) resumes execution, assigning 42 to x, so it logs "got 42".