Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.

Well done!

You have completed (UPI) Chapter 11: Managing Errors, Debugging, and Handling Events in JavaScript!

Instruction

Iterating over a generator

Generator functions are functions you call to produce an iterable object.

function* generate(a, b) {
 yield a;
 yield b;
}
for (const x of generate) {
 console.log(x);
} // TypeError: generate is not iterable

When they are not called, the Function object corresponding to the generator is callable, but not iterable. Calling a generator produces an iterable object which will...