News for hackers. Stuff that matters.
Re:Callbacks as our Generation's Goto Statement by just2n on Thursday August 15, 2013 @07:48PM (#6221344)
Coroutines (or generators) are a really nice sugar for callbacks. This looks a lot like ES6's yield, just s/await/yield/.

But to answer your question, since these can't be done in parallel, you'd have to keep track of which player you're asking:

    var playersAsked = 0;
    var askNextPlayerHisName = function(done){
        if (playersAsked === players.length) done();

        Ask("What's your name?", function(name){
            if (IsValidName(name)){
                players[playersAsked].name = name;
                playersAsked++;
            }
            askNextPlayerHisName(done);   
        });
    };
    askNextPlayerHisName(function(){/*...*/});
Re:Callbacks as our Generation's Goto Statement by hokkos on Thursday August 15, 2013 @08:41PM (#6221527)
Just hope that the players won't enter too much invalid names : http://stackoverflow.com/a/7828803/260556
Re:Callbacks as our Generation's Goto Statement by just2n on Thursday August 15, 2013 @08:44PM (#6221539)
Not quite in this case. I'm making an assumption that the Ask function provided by the parent is actually asynchronous.