I was going through an article about generators. Stumbled upon this
function* gen() {
let result = yield "2 + 2 = ?"; // (*)
alert(result);
}
let generator = gen();
let question = generator.next().value;
generator.next(4);
In above code why it doesn't alert "2 + 2 = ?" in the function? and how is it waiting for the result to be passed and alerting that ??