Example for Generators in Javascript