Here is a function that I would like to call for its return value, and in that function I would like to use an async call that would set a flag to work with later on:
function getSomething() {
    var isOk;
    myAsyncFunction(function(data) {
        if (data === 'foo') {
            isOk = true;
        }
    });
    //...
    if (isOk) {
        return true;
    }
}
I would want to use getSomething() like this:
if (getSomething()) {...}
I know that it won't pause the execution of this function to wait for my async call to finish. I also know that the return true statement should not be in the callback of the async function. But how can I wait for the async function's callback? Should I transform my getSomething() call to a promise or is there another way? And how would be the call of getSomething() look like if I'd use promises? Thanks in advance!
 
    