Hint
Generators pause at yield. When the function completes, done becomes true.
function* gen() {
yield 1;
yield 2;
}
const g = gen();
console.log(g.next().value);
console.log(g.next().value);
console.log(g.next().done);1 2 true
Explanation: First next(): value=1, done=false. Second: value=2, done=false. Third: function ends, done=true.
Key Insight: Generators pause at yield. When the function completes, done becomes true.