I have a function "fill" which fills an array with numbers, and I want to do it as long as this array has empty values. But it want a delay of one second for each number.
I found here on stackoverflow a solution for how to use setTimeOut with loop, but my problem is different, as the loop will break depending on a boolean. This is what I got so far, using the same idea:
var fillCache = function () {
var i = state.cache.indexOf("")
while (i !== -1) {
(function (i) {
setTimeout(function () { fill }, 1000)
})
i = state.cache.indexOf("")
}
}
What I get is an error saying "expected an assignment or function call and instead saw an expression" for Line 4. Any idea? Or am I completely wrong?