Generator functions are basically functions that you can pause at some point. You can define a generator function with function*
:
function* Generator() {
// code goes here
}
I like to named my generator functions with a capital, for reasons that will become apparent later, but generally they are named with a lowercase letter.