I’m using `snapshot.forEach(function(item) {})` to get each thing inside of a reference. The site I’m making is actually a live quiz game (like Kahoot, Quizizz, etc.) so I’m using the forEach function to get each question of a quiz. The thing is, I want to yield/pause the script at the end of the function, and wait for the player/user to answer the question, then stop yielding so it goes to the next question. The other day I figured out the `yield` operator. And it did as I thought: it paused the script at the first question. But then I tried putting `continue` right after it, for testing, and it still stayed at the first question. I also tried putting `yield` in a variable and doing `yield.next()`, because I saw that somewhere, but it did not work either. How can I sort of “continue”/unpause the script after a yield?
@BostauthorDec 03.2021 — #@Sempervivum#1640055 This did not help me. Because I don't think there's any other option besides forEach loop for a DataSnapshot from Firebase.
@SempervivumDec 11.2021 — #I tested this code and it's working fine: ``<i> </i> const snapshot = [1, 2, 4, 8]; // just for testing
let helperArr = []; snapshot.forEach(function (item) { helperArr.push(item); }); function* gen(arr) { for (let item of arr) { // return item and wait for next request: yield item; } } const g = gen(helperArr); console.log(g.next().value); console.log(g.next().value); console.log(g.next().value); console.log(g.next().value);<i> </i>`` Check if you can adjust it to your situation.