
Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
This question tests understanding of two-way communication between generator functions and the code that evaluates the generator. It is a powerful technique which is used in libraries such as redux-saga.
You can pass a value value to a generator function X by calling generator.next(X). Then in the generator function, you can access this value by calling let X = yield "val to pass into generator.next()";
You can throw an error back to a generator function by calling generator.throw(err). If this error isn't caught in the generator function, that will throw an error.