I have This javascript code does not work normally .
var asyncFunction = function () {
    setTimeout(function () {
        return 'accepted';
    }, Math.floor(Math.random() * 5000));
};
var Applicant;
(Applicant = function (applicant_name_var, applicant_age_var) {
    name = applicant_name_var;
    a = applicant_age_var;
    return {
        who_AM_I: function () {
            if (name == null) { return 'No Name'; }
            else {
                return name;
            }
        },
        isAdult: function () {
            if (a == null) {
                return false;
            } else
                if (a < 18) {
                    return false;
                } else {
                    return true;
                }
        },
        INTERVIEWRESULT: function () {
            var result = 'pending';
            result = asyncFunction();
            return result;
        }
    };
}).call();
console.log('debut');
var pending_APPLICANT = [];
var accepted_APPLICANT = [];
var applicant1 = new Applicant('John Doe');
var applicant2 = new Applicant();
var applicant3 = new Applicant('Jane Doe', 24);
pending_APPLICANT.push(applicant1);
pending_APPLICANT.push(applicant2);
pending_APPLICANT.push(applicant3);
if (applicant1.INTERVIEWRESULT() == 'accepted') {
    accepted_APPLICANT.push(applicant1);
    pending_APPLICANT.splice(1, 2);
}
if (applicant2.INTERVIEWRESULT() == 'accepted') {
    accepted_APPLICANT.push(applicant2);
    pending_APPLICANT.splice(1, 1);
}
if (applicant3.INTERVIEWRESULT() == 'accepted') {
    accepted_APPLICANT.push(applicant3);
    pending_APPLICANT.splice(0, 1);
}
console.log('Pending applicants:');
for (var i = 0; i < pending_APPLICANT.length; i++) {
    console.log(pending_APPLICANT[i].toString());
}
console.log('Accepted applicants:');
for (var i = 0; i < accepted_APPLICANT.length; i++) {
    console.log(accepted_APPLICANT[i].toString());
}
the output of this code is :
> debut
> Pending applicants:
> [object Object]
> [object Object]
> [object Object]
> Accepted applicants:
The expected output is something like that:
> Pending applicants:
> No one.
> Accepted applicants:
> Name: Jane Doe | Age: 24 | Adult: true
> Name: John Doe | Age: Unknown | Adult: false
> Name: No Name | Age: Unknown | Adult: false
I think the problem is in the asyuncFunction()
 
     
    