I have a piece of code:
var a = false;
function wait(milliseconds, async) {
if(!async) {
setTimeout(function() {
        console.log('Sync timer done.');
        a = true;
        return true;
    }, milliseconds*1000);
}
(...)
f_recipe.forEach(function(item, index) {
    if (obj['actual_step'] != 0 && obj['actual_step'] != index ) {
            e = "Desync";
        throw e;
    };
    console.log("Step: " + obj.actual_step);
    if(item.substr(item.length - 6) != "false)"){
        if (eval(item)) {
        obj['actual_step']++;
        }
    } else {
        eval(item);
        var ival = setInterval(function(){
            if(a) {
                console.log('do the next thing');
                clearInterval(ival);
            }
        }, 1000);
    }
});
But when I get to 'do the next thing'(interval complete), the forEach loop doesn't continue to the next element of the array. 'a' is set to true after timeout (kind of a synchronous wait in JS). f_recipes is a string array with function call (e.g. 'wait(20, false)').
How to get it to work?
 
    