d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Javascript Generator Function
Add Reply New Topic New Poll
Member
Posts: 9,837
Joined: Feb 20 2011
Gold: 4,815.00
Oct 9 2018 02:52pm
Ok guys, here is my code.

I've just started learning Generators in JS and I'm not quite sure I understrand them fully.



What I want to achieve:

The last step (yield arr) of the generator needs to return an array of the arguments passed to thegen2.next() method.
If I decide to add a newgen2.next('TEST') at the end of my code, it needs to be added to the returned array.
If my last call is empty, aka gen2.next() I want the full array back.

Can anyone help me ? How should I start ? Any tips or anything ?

This post was edited by TaGueule on Oct 9 2018 02:53pm
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll