I am trying to sort names in two different array. but when I need to return the final result, it will just return the values first then do the forEach.
const available = [];
const taken = [];
const names = data.split('\n');
names.forEach(async (name, i) => {
(data.success !== undefined) ? (availabe.push(name)) : (taken.push(name));
});
return { //This returns 0 for both
available: available.length,
taken: taken.length
}