Open stlouisweb opened 8 years ago
I had this problem, too. Looking around for solution, I finally resented to just using a good old for
loop like this:
co(function* () { // assuming you are somewhere in a co'ed function
for (let i = 0; i < defaultVars, i++)
// do something awesome with generators
var value = yield prompt(defaultVars[i] + ': ');
console.log(value);
}
yield handleFinish;
});
It would be nice if some Javascript-ninja had a better solution though.
I want to loop through an array and create a series of prompts based off of this array. I seem to be having trouble stopping the loop in order to collect each prompt sequentially. For Example, if I have an array named DefaultArray, I want to create a prompt for each item in the DefaultArray:
Suppose DefaultArray = ['Do you like Apples?', 'Do you like Oranges?'];
I would expect to see: Do you like Apples?: yes yes Do you like Oranges?: no no
Instead I see: Do you like Apples?:Do you like Oranges?: yes yes yes