I can't get my head around how to return the value from uniqueCheck() to isValid. I've added in a setTimeout to simulate the async operation.
function isValid(data) {
    uniqueCheck(data, function(val) {
        return val;
        //true
    });
    // need the value here
}
function uniqueCheck(data, cb) {
    // do something with data async
    setTimeout(function () {
        cb(true)
    }, 1000);
}
console.log(isValid("some data"));
 
     
    